本文整理汇总了C++中OSSchedLock函数的典型用法代码示例。如果您正苦于以下问题:C++ OSSchedLock函数的具体用法?C++ OSSchedLock怎么用?C++ OSSchedLock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OSSchedLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delay_osschedlock
//us级延时时,关闭任务调度(防止打断us级延迟)
void delay_osschedlock(void)
{
#ifdef CPU_CFG_CRITICAL_METHOD //使用UCOSIII
OS_ERR err;
OSSchedLock(&err); //UCOSIII的方式,禁止调度,防止打断us延时
#else //否则UCOSII
OSSchedLock(); //UCOSII的方式,禁止调度,防止打断us延时
#endif
}
示例2: get_usb_logger_data
INT32U get_usb_logger_data(void)
{
INT32U ret = 0;
/* read operation */
#if _OPERATING_SYSTEM != _OS_NONE // Soft Protect for critical section
OSSchedLock();
#endif
ret = (INT32U)logger_read_ptr;
//memcpy((CHAR*)dataptr, usb_read_ptr, USB_LOGGER_BUF_SIZE);
if(logger_read_ptr == logger_write_ptr)
{
logger_read_ptr[0] = 0;
}
else
{
if(logger_read_ptr < (usb_logger_buf + USB_LOGGER_BUF_TOTAL_SIZE - USB_LOGGER_BUF_SIZE))
logger_read_ptr += USB_LOGGER_BUF_SIZE;
else
logger_read_ptr = usb_logger_buf;
}
//loggerwritecnt = (logger_write_ptr - usb_logger_buf) >> 9;
//loggerreadcnt = (logger_read_ptr - usb_logger_buf) >> 9;
#if _OPERATING_SYSTEM != _OS_NONE //exit critical section
OSSchedUnlock();
#endif
return ret;
}
示例3: zyThreadDel
/*********************************************************************************************************
** Function name: zyThreadDel
** Descriptions: 删除线程
** input parameters: ulThreadId: 线程ID
** output parameters: none
** Returned value: zy_OK: 成功
** 负数: 错误,绝对值参考zy_if.h
** Created by: Chenmingji
** Created Date: 2009-07-23
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
*********************************************************************************************************/
INT32S zyThreadDel (unsigned long ulThreadId)
{
OS_TCB *ptcbTask; /* 任务TCB */
void *pvTmp1;
ptcbTask = (OS_TCB *)ulThreadId;
if (zyThreadGetCurId() == ulThreadId) {
zyIrqDisable();
pvTmp1 = (void *)(ptcbTask->OSTCBStkPtr);
zyHeapFree(pvTmp1);
OSTaskDel(ptcbTask->OSTCBPrio);
zyIrqEnable();
return ZY_OK;
}
OSSchedLock();
pvTmp1 = (void *)(ptcbTask->OSTCBStkPtr);
zyHeapFree(pvTmp1);
OSTaskDel(ptcbTask->OSTCBPrio);
OSSchedUnlock();
return ZY_OK;
}
示例4: zyThreadCreate
/*********************************************************************************************************
** Function name: zyThreadCreate
** Descriptions: 建立线程
** input parameters: pvThreedMain: 线程主程序
** pvArg: 给线程的参数
** uiPrio: 线程优先级
** ulSize: 堆栈大小
** output parameters: none
** Returned value: 线程ID,0为不成功
** Created by: Chenmingji
** Created Date: 2009-07-23
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
*********************************************************************************************************/
unsigned long zyThreadCreate (void *pvThreedMain, void *pvArg, unsigned int uiPrio, INT32U ulSize)
{
OS_STK *pstpTmp1;
OS_TCB **pptcpTmp2;
unsigned long ulRt;
pstpTmp1 = (OS_STK *)zyHeapMalloc(ulSize * sizeof(OS_STK));
if (pstpTmp1 == NULL) {
return 0;
}
OSSchedLock();
if (OSTaskCreate((void (*) (void *))pvThreedMain,
pvArg,
#if OS_STK_GROWTH == 1
pstpTmp1 + ulSize - 1,
#else
pstpTmp1,
#endif /* OS_STK_GROWTH */
(INT8U)uiPrio) != OS_NO_ERR) {
OSSchedUnlock();
return 0;
}
pptcpTmp2 = OSTCBPrioTbl;
ulRt = (unsigned long)pptcpTmp2[uiPrio];
OSSchedUnlock();
return ulRt;
}
示例5: OSA_MemFree
/*FUNCTION**********************************************************************
*
* Function Name : OSA_MemFree
* Description : This function is used to free the memory previously allocated.
*
*END**************************************************************************/
osa_status_t OSA_MemFree(void *ptr)
{
OSSchedLock();
free(ptr);
OSSchedUnlock();
return kStatus_OSA_Success;
}
示例6: setclock
/*
* This function sets the system clock time.
*/
int setclock(alt_u32 seconds)
{
struct timeval time = {0, 0};
struct timezone zone = {0, 0};
/*
* NTP Time is seconds since 1900
* Convert to Unix time which is seconds since 1970
*/
seconds -= NTP_TO_UNIX_TIME;
time.tv_sec = seconds;
printf("Setting System Clock time to: %s\n",ctime(&time.tv_sec));
//settimeofday() can not be called at the same time as gettimeofday()
OSSchedLock();
//settimeofday(&time, &zone);
if(settimeofday(&time, &zone) < 0)
{
printf("Error set the time of day %s\n", strerror(errno));
exit(0);
}
OSSchedUnlock();
return 0;
}
示例7: StackSize
INT8U CTask::Create(bool bRunNow)
{
INT32U nStackSize = StackSize();
m_nId = s_nNextId ++;
OSSchedLock();
INT8U errno = OSTaskCreateExt(_callbackFunc, (void*)this,
&m_pTaskStack[nStackSize-1],
m_nPrio,
m_nId,
m_pTaskStack,
nStackSize,
(void*)NULL,
OS_TASK_OPT_STK_CHK|OS_TASK_OPT_STK_CLR);
if (!errno){
OSTaskNameSet(m_nPrio, (INT8U*)m_aTaskName, &errno);
}
if (!bRunNow){
OSTaskSuspend(m_nPrio);
}
OSSchedUnlock();
return errno;
}
示例8: Function
void Function(void)
{
OSSchedLock();
/*
you can access shared data in here (interrupts are still recoginizeds)
*/
OSSchedUnlock();
}
示例9: adi_osal_SchedulerLock
void adi_osal_SchedulerLock( void )
{
OSSchedLock();
#ifdef OSAL_DEBUG
_adi_osal_gnSchedulerLockCnt++;
#endif /* OSAL_DEBUG */
return;
}
示例10: msgQQuery
INT8U msgQQuery(MSG_Q_ID msgQId, OS_Q_DATA *pdata)
{
INT8U ret;
OSSchedLock();
ret = OSQQuery(msgQId->pEvent, pdata);
OSSchedUnlock();
return ret;
}
示例11: alt_ucosii_check_return_code
void alt_ucosii_check_return_code(INT8U return_code)
{
if(return_code != OS_NO_ERR)
{
OSSchedLock(); /* Disable Task Switching but still service other IRQs */
alt_ucosii_simple_error_handler(return_code);
OSSchedUnlock(); /* Enable Task Switching */
}
}
示例12: OS_TmrTask
void OS_TmrTask (void *p_arg)
{
OS_ERR err;
OS_TMR_CALLBACK_PTR p_fnct;
OS_TMR *p_tmr;
OS_TMR *p_tmr_next;
CPU_TS ts;
CPU_TS ts_start;
CPU_TS ts_delta;
(void)&p_arg; /* Not using 'p_arg', prevent compiler warning */
while (DEF_ON) {
(void)OSTaskSemPend((OS_TICK )0, /* Wait for signal indicating time to update tmrs */
(OS_OPT )OS_OPT_PEND_BLOCKING,
(CPU_TS *)&ts,
(OS_ERR *)&err);
OS_TmrLock();
ts_start = OS_TS_GET();
OSTmrTickCtr++; /* Increment the current time */
p_tmr = OSTmrListPtr;
while (p_tmr != (OS_TMR *)0) { /* Update all the timers in the list */
OSSchedLock(&err);
(void)&err;
p_tmr_next = p_tmr->NextPtr;
p_tmr->Remain--;
if (p_tmr->Remain == 0) {
if (p_tmr->Opt == OS_OPT_TMR_PERIODIC) {
p_tmr->Remain = p_tmr->Period; /* Reload the time remaining */
} else {
OS_TmrUnlink(p_tmr); /* Remove from list */
p_tmr->State = OS_TMR_STATE_COMPLETED; /* Indicate that the timer has completed */
}
p_fnct = p_tmr->CallbackPtr; /* Execute callback function if available */
if (p_fnct != (OS_TMR_CALLBACK_PTR)0) {
(*p_fnct)((void *)p_tmr,
p_tmr->CallbackPtrArg);
}
}
p_tmr = p_tmr_next;
OSSchedUnlock(&err);
(void)&err;
}
ts_delta = OS_TS_GET() - ts_start; /* Measure execution time of timer task */
if (OSTmrTaskTimeMax < ts_delta) {
OSTmrTaskTimeMax = ts_delta;
}
OS_TmrUnlock();
}
}
示例13: OSA_MemAllocZero
/*FUNCTION**********************************************************************
*
* Function Name : OSA_MemAllocZero
* Description : This function is used to allocate amount of memory in bytes
* and initializes it to 0.
* Return the pointer to the memory if success, otherwise return NULL;
*
*END**************************************************************************/
void * OSA_MemAllocZero(size_t size)
{
void *pMem;
OSSchedLock();
pMem = calloc(1, size);
OSSchedUnlock();
return pMem;
}
示例14: OSA_MemAlloc
/*FUNCTION**********************************************************************
*
* Function Name : OSA_MemAlloc
* Description : This function is used to allocate amount of memory in bytes.
* Return the pointer to the memory if success, otherwise return NULL;
*
*END**************************************************************************/
void * OSA_MemAlloc(size_t size)
{
void *pMem;
OSSchedLock();
pMem = malloc(size);
OSSchedUnlock();
return pMem;
}
示例15: OSA_EnterCritical
/*FUNCTION**********************************************************************
*
* Function Name : OSA_EnterCritical
* Description : This function is used to ensure some code will not be preempted.
*
*END**************************************************************************/
void OSA_EnterCritical(osa_critical_section_mode_t mode)
{
if (kCriticalDisableInt == mode)
{
OS_ENTER_CRITICAL();
}
else
{
OSSchedLock();
}
}