当前位置: 首页>>代码示例>>C++>>正文


C++ EnterCritical函数代码示例

本文整理汇总了C++中EnterCritical函数的典型用法代码示例。如果您正苦于以下问题:C++ EnterCritical函数的具体用法?C++ EnterCritical怎么用?C++ EnterCritical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了EnterCritical函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ES_DeQueue

/****************************************************************************
 Function
   ES_DeQueue
 Parameters
   unsigned char * pBlock : pointer to the block of memory in use as the Queue
   ES_Event * pReturnEvent : used to return the event pulled from the queue
 Returns
   The number of entries remaining in the Queue
 Description
   pulls next available entry from Queue, EF_NO_EVENT if Queue was empty and
   copies it to *pReturnEvent.
 Notes

 Author
   J. Edward Carryer, 08/09/11, 19:11
****************************************************************************/
uint8_t ES_DeQueue( ES_Event * pBlock, ES_Event * pReturnEvent )
{
   pQueue_t pThisQueue;
   uint8_t NumLeft;

   pThisQueue = (pQueue_t)pBlock;
   if ( pThisQueue->NumEntries > 0)
   {
      EnterCritical();   // save interrupt state, turn ints off
      *pReturnEvent = pBlock[ 1 + pThisQueue->CurrentIndex ];
      // inc the index
      pThisQueue->CurrentIndex++;
      // this way we only do the modulo operation when we really need to
      if (pThisQueue->CurrentIndex >=  pThisQueue->QueueSize)
         pThisQueue->CurrentIndex = (uint8_t)(pThisQueue->CurrentIndex % pThisQueue->QueueSize);
      //dec number of elements since we took 1 out
      NumLeft = --pThisQueue->NumEntries; 
      ExitCritical();  // restore saved interrupt state
   }else { // no items left in the queue
      (*pReturnEvent).EventType = ES_NO_EVENT;
      (*pReturnEvent).EventParam = 0;
      NumLeft = 0;
   }
   return NumLeft;
}
开发者ID:NitinBandaru,项目名称:Test,代码行数:41,代码来源:ES_Queue.c

示例2: while

void NativeSoundMix::DoPlay()
{
	while ( true ) {
		// Wait for a buffer done event
		WaitForSingleObject(playEvent, 10*1000);
		EnterCritical();
		if ( !hWaveOut || !playEvent ) {
			LeaveCritical();
			return;
		}

		// If a buffer is done, fill it...
		int nSent = 0;
		for ( int i = 0; i < nBuffers; i++ ) {
			WAVEHDR* hdr = waveHDR+i;
			if ( (hdr->dwFlags & WHDR_DONE) || !(hdr->dwFlags & WHDR_PREPARED) ) {
				if ( buffer[i] )
				{
	 				BuildAndWrite( &waveHdr[i], false );
				}
// 				SendBuffer(i);
				nSent++;
			}
		}

		if ( nSent > nBuffers-2 ) 
			EnlargeBuffers();

		if ( nSilent > nBuffers ) 
			CloseDevice();
		LeaveCritical();
	}
}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:33,代码来源:sound.cpp

示例3: SetCV

/*
** ===================================================================
**     Method      :  SetCV (component FreeCntr8)
**
**     Description :
**         Sets compare or preload register value. The method is called 
**         automatically as a part of several internal methods.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void SetCV(word Val)
{
  EnterCritical();                     /* Disable global interrupts */
  setReg(TMR0_CMPLD1,Val);             /* Store given value to the compare preload 1 register */
  setReg(TMR0_CMPLD2,Val);             /* Store given value to the compare preload 2 register */
  ExitCritical();                      /* Enable global interrupts */
}
开发者ID:sk3tch,项目名称:Freescale-RFID-Emulator,代码行数:17,代码来源:FC81.c

示例4: FCALC_GFD_DutyCycle_Decode

U8 FCALC_GFD_DutyCycle_Decode(U8 frequency){
	U16 local_DutyCycleCopy = 0;
	EnterCritical();
	local_DutyCycleCopy = M_PE6_Frequency_calc_DutyCycle;
	ExitCritical();
	
	switch (frequency)
	{
		case 50:
			return 100-local_DutyCycleCopy / 50;
			break;
		case 40:
			return 100-local_DutyCycleCopy / 62;
			break;
		case 30:
			return 100-local_DutyCycleCopy / 83;
			break;
		case 20:
			return 100-local_DutyCycleCopy / 125;
			break;
		case 10:
			return 100-local_DutyCycleCopy / 250;
			break;
		default:
			return 0;
	}
}
开发者ID:Skyturtle,项目名称:dashboard,代码行数:27,代码来源:FCALC_Frequency.c

示例5: LoadTicks

/*
** ===================================================================
**     Method      :  LoadTicks (component FreeCntr8)
**
**     Description :
**         Loads actual number of timer ticks from internal variable. The 
**         method is called automatically as a part of several internal 
**         methods.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void LoadTicks(void)
{
  EnterCritical();                     /* Disable global interrupts */
  LTicks = TTicks;                     /* Loading actual number of timer ticks */
  LOvf = TOvf;                         /* Loading actual state of "overflow flag" */
  ExitCritical();                      /* Enable global interrupts */
}
开发者ID:sk3tch,项目名称:Freescale-RFID-Emulator,代码行数:18,代码来源:FC81.c

示例6: route_delete

int
route_delete(ipaddr_t net, ipaddr_t netmask) {
  int i,ret;
  route_entry_p routep;

  mk_ip_table_rw();
  EnterCritical();
  i = get_routen(net,netmask);
  if (i == -1) {
    /* not found */
    fprintf(stderr,"Route not found\n");
    ret = -1;
  } else if (i == GETNUMROUTEENTRIES - 1) {
    /* last route */
    DECNUMROUTEENTRIES;
    ret = 0;
  } else {
    /* shift up all entries */
    for (  ; i < GETNUMROUTEENTRIES ; i++) {
      routep = GETROUTEP(i);
      *routep = *(GETROUTEP(i + 1));
    }
    DECNUMROUTEENTRIES;
    ret = 0;
  }
  ExitCritical();
  mk_ip_table_ro();
  return ret;

}
开发者ID:aunali1,项目名称:exopc,代码行数:30,代码来源:routenif.c

示例7: MFSOpenFile

//Returns 0 on succses.
//Returns size of file if non-empty
//If positive, populates mfi.
//Returns -1 if can't find file or reached end of file list.
int8_t MFSOpenFile( const char * fname, struct MFSFileInfo * mfi )
{
	if( mfs_at == 0 )
	{
		FindMPFS();
	}
	if( mfs_at == 0 )
	{
		return -1;
	}

	EnterCritical();
	flashchip->chip_size = 0x01000000;
	uint32 ptr = mfs_at;
	struct MFSFileEntry e;
	while(1)
	{
		spi_flash_read( ptr, (uint32*)&e, sizeof( e ) );		
		ptr += sizeof(e);
		if( e.name[0] == 0xff || ets_strlen( e.name ) == 0 ) break;

		if( ets_strcmp( e.name, fname ) == 0 )
		{
			mfi->offset = e.start;
			mfi->filelen = e.len;
			flashchip->chip_size = 0x00080000;
			ExitCritical();
			return 0;
		}
	}
	flashchip->chip_size = 0x00080000;
	ExitCritical();
	return -1;
}
开发者ID:SiwyDym,项目名称:esp8266ws2812i2s,代码行数:38,代码来源:mfs.c

示例8: TimerStartKernelTimer

unsigned TimerStartKernelTimer (TTimer *pThis, unsigned nDelay, TKernelTimerHandler *pHandler, void *pParam, void *pContext)
{
	assert (pThis != 0);

	EnterCritical ();

	unsigned hTimer;
	for (hTimer = 0; hTimer < KERNEL_TIMERS; hTimer++)
	{
		if (pThis->m_KernelTimer[hTimer].m_pHandler == 0)
		{
			break;
		}
	}

	if (hTimer >= KERNEL_TIMERS)
	{
		LeaveCritical ();

		LoggerWrite (LoggerGet (), "timer", LogPanic, "System limit of kernel timers exceeded");

		return 0;
	}

	assert (pHandler != 0);
	pThis->m_KernelTimer[hTimer].m_pHandler    = pHandler;
	pThis->m_KernelTimer[hTimer].m_nElapsesAt  = pThis->m_nTicks+nDelay;
	pThis->m_KernelTimer[hTimer].m_pParam      = pParam;
	pThis->m_KernelTimer[hTimer].m_pContext    = pContext;

	LeaveCritical ();

	return hTimer+1;
}
开发者ID:AdamRLukaitis,项目名称:uspi,代码行数:34,代码来源:timer.c

示例9: ifconfig

/* INTERFACE MANAGEMENT */
int
ifconfig(char *name, 
	 int flags, 
	 ipaddr_t ipaddr, 
	 ipaddr_t netmask, 
	 ipaddr_t broadcast) {
  if_entry_p ife;
  int ret;
  mk_ip_table_rw();
  EnterCritical();
  if ((ife = get_if_by_name(name))) {
    bcopy(ipaddr, ife->ipaddr, 4);
    bcopy(netmask, ife->netmask, 4);
    bcopy(broadcast, ife->broadcast, 4);
    apply_netmask(ife->net, ipaddr, netmask);
    ife->flags = flags;
    ret = 0;
  } else {
    fprintf(stderr,"ifconfig: Device not found: %s\n",name);
    ret = -1;
  }
  ExitCritical();
  mk_ip_table_ro();
  return ret;
}
开发者ID:aunali1,项目名称:exopc,代码行数:26,代码来源:routenif.c

示例10: assert

TString *TimerGetTimeString (TTimer *pThis)
{
	assert (pThis != 0);

	EnterCritical ();

	unsigned nTime = pThis->m_nTime;
	unsigned nTicks = pThis->m_nTicks;

	LeaveCritical ();

	if (nTicks == 0)
	{
		return 0;
	}

	unsigned nSecond = nTime % 60;
	nTime /= 60;
	unsigned nMinute = nTime % 60;
	nTime /= 60;
	unsigned nHours = nTime;

	nTicks %= HZ;
#if (HZ != 100)
	nTicks = nTicks * 100 / HZ;
#endif

	TString *pString = malloc (sizeof (TString));
	assert (pString != 0);
	String (pString);

	StringFormat (pString, "%02u:%02u:%02u.%02lu", nHours, nMinute, nSecond, nTicks);

	return pString;
}
开发者ID:AdamRLukaitis,项目名称:uspi,代码行数:35,代码来源:timer.c

示例11: SMasterLdd3_SendBlock

/* ===================================================================*/
LDD_TError SMasterLdd3_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, uint16_t Size)
{
  /* Clock configuration test - this test can be disabled by setting the "Ignore clock configuration test"
     property to the "yes" value in the "Configuration inspector" */
  if (!((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnMode) { /* Is the device disabled in the actual speed CPU mode? */
    return ERR_SPEED;                  /* If yes then error */
  }
  /* Device state test - this test can be disabled by setting the "Ignore enable test"
     property to the "yes" value in the "Configuration inspector" */
  if (!((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->EnUser) { /* Is the device disabled by user? */
    return ERR_DISABLED;               /* If yes then error */
  }
  if (((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq != 0x00U) { /* Is the previous transmit operation pending? */
    return ERR_BUSY;                   /* If yes then error */
  }
  /* {Default RTOS Adapter} Critical section begin, general PE function is used */
  EnterCritical();
  ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataPtr = (uint8_t*)BufferPtr; /* Set a pointer to the output data. */
  ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutDataNumReq = Size; /* Set the counter of characters to be sent. */
  ((SMasterLdd3_TDeviceDataPtr)DeviceDataPtr)->OutSentDataNum = 0x00U; /* Clear the counter of sent characters. */
  SPI_PDD_EnableDmasInterrupts(SPI2_BASE_PTR, SPI_PDD_TX_FIFO_FILL_INT_DMA); /* Enable TX interrupt */
  /* {Default RTOS Adapter} Critical section end, general PE function is used */
  ExitCritical();
  return ERR_OK;                       /* OK */
}
开发者ID:LoicGuillain,项目名称:Freescale,代码行数:26,代码来源:SMasterLdd3.c

示例12: portTASK_FUNCTION

/**
 * \brief Touch Task. Starts and stops walking Task by touchsensor.
 * @param TouchTask Taskname
 * @param pvParameters Not used
 * @return void
 */
static portTASK_FUNCTION(TouchTask, pvParameters) {
	uint8_t errCode;
	uint16_t touchStatus;

	(void)pvParameters;
	TOUCH_init();
  WAIT1_WaitOSms(10);
  for(;;) {
    errCode=TOUCH_getELE(&touchStatus);
    if(errCode != ERR_OK) {
      for(;;) {} /* error occurred!*/
    }
    if(touchStatus!=0) {
      if (enabledWalking) {
        EnterCritical();
        if(enabledWalking) { /* stop walking*/
          enabledWalking = FALSE;
        } else { /* start walking*/
          enabledWalking = TRUE;
        }
        ExitCritical();
      }
      WAIT1_WaitOSms(1000);
    }
    WAIT1_WaitOSms(16); /* 16ms sampling time*/
  }
}
开发者ID:3ben1189,项目名称:mcuoneclipse,代码行数:33,代码来源:Application.c

示例13: free

void free (void *pBlock)
{
	assert (pBlock != 0);
	TBlockHeader *pBlockHeader = (TBlockHeader *) ((unsigned long) pBlock - sizeof (TBlockHeader));
	assert (pBlockHeader->nMagic == BLOCK_MAGIC);

	for (TBlockBucket *pBucket = s_BlockBucket; pBucket->nSize > 0; pBucket++)
	{
		if (pBlockHeader->nSize == pBucket->nSize)
		{
			EnterCritical ();

			pBlockHeader->pNext = pBucket->pFreeList;
			pBucket->pFreeList = pBlockHeader;

#ifdef MEM_DEBUG
			pBucket->nCount--;
#endif

			LeaveCritical ();

			break;
		}
	}
}
开发者ID:Kokoro666,项目名称:Evangelion-Kernel,代码行数:25,代码来源:alloc.c

示例14: EnterCritical

void *PageAlloc(void)
{
	EnterCritical ();

#ifdef MEM_DEBUG
	if (++s_PageBucket.nCount > s_PageBucket.nMaxCount)
	{
		s_PageBucket.nMaxCount = s_PageBucket.nCount;
	}
#endif

	TFreePage *pFreePage;
	if ((pFreePage = s_PageBucket.pFreeList) != 0)
	{
		s_PageBucket.pFreeList = pFreePage->pNext;
		pFreePage->nMagic = 0;
	}
	else
	{
		pFreePage = (TFreePage *) s_pNextPage;
		
		s_pNextPage += PAGE_SIZE;

		if (s_pNextPage > s_pPageLimit)
		{
			LeaveCritical ();

			return 0;		// TODO: system should panic here
		}
	}

	LeaveCritical ();
	
	return pFreePage;
}
开发者ID:Nvreformat,项目名称:Siwka-OS,代码行数:35,代码来源:alloc.c

示例15: EnterCritical

void CPollQProducer::Run() {
	unsigned short usValue = ( unsigned short ) 0;
	BaseType_t xError = pdFALSE, xLoop;

	for( ;; )
	{
		for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ )
		{
			/* Send an incrementing number on the queue without blocking. */
			if( m_pQueue->Send((void*)&usValue, pollqNO_DELAY ) != pdPASS )
			{
				/* We should never find the queue full so if we get here there
				has been an error. */
				xError = pdTRUE;
			}
			else
			{
				if( xError == pdFALSE )
				{
					/* If an error has ever been recorded we stop incrementing the
					check variable. */
					EnterCritical();
						m_nPollingCount++;
					ExitCritical();
				}
					/* Update the value we are going to post next time around. */
				usValue++;
			}
		}
		/* Wait before we start posting again to ensure the consumer runs and
		empties the queue. */
		Delay(pollqPRODUCER_DELAY);
	}
}
开发者ID:dessel,项目名称:stf12,代码行数:34,代码来源:CPollQ.cpp


注:本文中的EnterCritical函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。