本文整理汇总了C++中OsSchedUnlock函数的典型用法代码示例。如果您正苦于以下问题:C++ OsSchedUnlock函数的具体用法?C++ OsSchedUnlock怎么用?C++ OsSchedUnlock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OsSchedUnlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoGetMemoryBuffer
/**
*******************************************************************************
* @brief Get a memory buffer from memory partition
* @param[in] mmID Specify memory partition that want to assign buffer.
* @param[out] None
* @retval NULL Assign buffer fail.
* @retval others Assign buffer successful,and return the buffer pointer.
*
* @par Description
* @details This function is called to Delete a memory partition.
*******************************************************************************
*/
void* CoGetMemoryBuffer(OS_MMID mmID)
{
P_MM memCtl;
P_MemBlk memBlk;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(mmID >= CFG_MAX_MM)
{
return NULL;
}
if( ((1<<mmID)&MemoryIDVessel) == 0)
{
return NULL;
}
#endif
memCtl = &MemoryTbl[mmID];
OsSchedLock(); /* Lock schedule */
if(memCtl->freeBlock == NULL ) /* Is there no free item in memory list */
{
OsSchedUnlock(); /* Unlock schedule */
return NULL; /* Yes,error return */
}
memBlk = (P_MemBlk)memCtl->freeBlock; /* Get free memory block */
memCtl->freeBlock = (U8*)memBlk->nextBlock; /* Reset the first free item */
OsSchedUnlock(); /* Unlock schedule */
return memBlk; /* Return free memory block address */
}
示例2: CoAcceptSem
/**
*******************************************************************************
* @brief Accept a semaphore without waitting
* @param[in] id Event ID
* @param[out] None
* @retval E_INVALID_ID Invalid event ID.
* @retval E_SEM_EMPTY No semaphore exist.
* @retval E_OK Get semaphore successful.
*
* @par Description
* @details This function is called accept a semaphore without waitting.
*******************************************************************************
*/
StatusType CoAcceptSem(OS_EventID id)
{
P_ECB pecb;
#if CFG_PAR_CHECKOUT_EN >0
if(id >= CFG_MAX_EVENT)
{
return E_INVALID_ID;
}
#endif
pecb = &EventTbl[id];
#if CFG_PAR_CHECKOUT_EN >0
if( pecb->eventType != EVENT_TYPE_SEM)
{
return E_INVALID_ID;
}
#endif
OsSchedLock();
if(pecb->eventCounter > 0) /* If semaphore is positive,resource available */
{
pecb->eventCounter--; /* Decrement semaphore only if positive */
OsSchedUnlock();
return E_OK;
}
else /* Resource is not available */
{
OsSchedUnlock();
return E_SEM_EMPTY;
}
}
示例3: CoDelFlag
/**
*******************************************************************************
* @brief Delete a flag
* @param[in] id Flag ID.
* @param[in] opt Delete option.
* @param[out] None
* @retval E_CALL Error call in ISR.
* @retval E_INVALID_ID Invalid event ID.
* @retval E_TASK_WAITTING Tasks waitting for the event,delete fail.
* @retval E_OK Event deleted successful.
*
* @par Description
* @details This function is called to delete a event flag.
* @note
*******************************************************************************
*/
StatusType CoDelFlag(OS_FlagID id,U8 opt)
{
P_FLAG_NODE pnode;
P_FCB pfcb;
pfcb = &FlagCrl;
if(OSIntNesting > 0) /* If be called from ISR */
{
return E_CALL;
}
#if CFG_PAR_CHECKOUT_EN >0
if((pfcb->flagActive&(1<<id)) == 0) /* Flag is valid or not */
{
return E_INVALID_ID;
}
#endif
OsSchedLock();
pnode = pfcb->headNode;
while(pnode != Co_NULL) /* Ready all tasks waiting for flags */
{
if((pnode->waitFlags&(1<<id)) != 0) /* If no task is waiting on flags */
{
if(opt == OPT_DEL_NO_PEND) /* Delete flag if no task waiting */
{
OsSchedUnlock();
return E_TASK_WAITING;
}
else if (opt == OPT_DEL_ANYWAY) /* Always delete the flag */
{
if(pnode->waitType == OPT_WAIT_ALL)
{
/* If the flag is only required by NODE */
if( pnode->waitFlags == (1<<id) )
{
/* Remove the NODE from waiting list */
pnode = RemoveFromLink(pnode);
continue;
}
else
{
pnode->waitFlags &= ~(1<<id); /* Update waitflags */
}
}
else
{
pnode = RemoveFromLink(pnode);
continue;
}
}
}
pnode = pnode->nextNode;
}
/* Remove the flag from the flags list */
pfcb->flagActive &= ~(1<<id);
pfcb->flagRdy &= ~(1<<id);
pfcb->resetOpt &= ~(1<<id);
OsSchedUnlock();
return E_OK;
}
示例4: CoCreateTmr
/**
*******************************************************************************
* @brief Create a timer
* @param[in] tmrType Specify timer's type.
* @param[in] tmrCnt Specify timer initial counter value.
* @param[in] tmrReload Specify timer reload value.
* @param[in] func Specify timer callback function entry.
* @param[out] None
* @retval E_CREATE_FAIL Create timer fail.
* @retval others Create timer successful.
*
* @par Description
* @details This function is called to create a timer.
*******************************************************************************
*/
OS_TCID CoCreateTmr(U8 tmrType, U32 tmrCnt, U32 tmrReload, vFUNCPtr func)
{
U8 i;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if((tmrType != TMR_TYPE_ONE_SHOT) && (tmrType != TMR_TYPE_PERIODIC))
{
return E_CREATE_FAIL;
}
if(func == NULL)
{
return E_CREATE_FAIL;
}
#endif
OsSchedLock(); /* Lock schedule */
for(i = 0; i < CFG_MAX_TMR; i++)
{
if((TmrIDVessel & (1u << i)) == 0) /* Is free timer ID? */
{
TmrIDVessel |= (1u<<i); /* Yes,assign ID to this timer */
OsSchedUnlock(); /* Unlock schedule */
TmrTbl[i].tmrID = i; /* Initialize timer as user set */
TmrTbl[i].tmrType = tmrType;
TmrTbl[i].tmrState = TMR_STATE_STOPPED;
TmrTbl[i].tmrCnt = tmrCnt;
TmrTbl[i].tmrReload = tmrReload;
TmrTbl[i].tmrCallBack = func;
TmrTbl[i].tmrPrev = NULL;
TmrTbl[i].tmrNext = NULL;
return i; /* Return timer ID */
}
}
OsSchedUnlock(); /* Unlock schedule */
return E_CREATE_FAIL; /* Error return */
}
示例5: CoCreateMemPartition
/**
*******************************************************************************
* @brief Create a memory partition
* @param[in] memBuf Specify memory partition head address.
* @param[in] blockSize Specify memory block size.
* @param[in] blockNum Specify memory block number.
* @param[out] None
* @retval E_CREATE_FAIL Create memory partition fail.
* @retval others Create memory partition successful.
*
* @par Description
* @details This function is called to create a memory partition.
*******************************************************************************
*/
OS_MMID CoCreateMemPartition(U8* memBuf,U32 blockSize,U32 blockNum)
{
U8 i,j;
U8 *memory;
P_MemBlk memBlk;
memory = memBuf;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(memBuf == NULL)
{
return E_CREATE_FAIL;
}
if(blockSize == 0)
{
return E_CREATE_FAIL;
}
if((blockSize&0x3) != 0)
{
return E_CREATE_FAIL;
}
if(blockNum<=1)
{
return E_CREATE_FAIL;
}
#endif
OsSchedLock(); /* Lock schedule */
for(i = 0; i < CFG_MAX_MM; i++)
{
if((MemoryIDVessel & (1 << i)) == 0) /* Is free memory ID? */
{
MemoryIDVessel |= (1<<i); /* Yes,assign ID to this memory block */
OsSchedUnlock(); /* Unlock schedule */
MemoryTbl[i].memAddr = memory;/* Initialize memory control block*/
MemoryTbl[i].freeBlock = memory;
MemoryTbl[i].blockSize = blockSize;
MemoryTbl[i].blockNum = blockNum;
memBlk = (P_MemBlk)memory; /* Bulid list in this memory block*/
for(j=0;j<blockNum-1;j++)
{
memory = memory+blockSize;
memBlk->nextBlock = (P_MemBlk)memory;
memBlk = memBlk->nextBlock;
}
memBlk->nextBlock = NULL;
return i; /* Return memory block ID */
}
}
OsSchedUnlock(); /* Unlock schedule */
return E_CREATE_FAIL; /* Error return */
}
示例6: CoPostMail
/**
*******************************************************************************
* @brief Post a mailbox
* @param[in] id Event ID.
* @param[in] pmail Pointer to mail that want to send.
* @param[out] None
* @retval E_INVALID_ID
* @retval E_OK
*
* @par Description
* @details This function is called to post a mail.
* @note
*******************************************************************************
*/
StatusType CoPostMail(OS_EventID id,void* pmail)
{
P_ECB pecb;
#if CFG_PAR_CHECKOUT_EN >0
if(id >= CFG_MAX_EVENT)
{
return E_INVALID_ID; /* Invalid id,return error */
}
#endif
pecb = &EventTbl[id];
#if CFG_PAR_CHECKOUT_EN >0
if(pecb->eventType != EVENT_TYPE_MBOX)/* Validate event control block type*/
{
return E_INVALID_ID; /* Event is not mailbox,return error*/
}
#endif
if(pecb->eventCounter == 0) /* If mailbox doesn't already have a message*/
{
OsSchedLock();
pecb->eventPtr = pmail; /* Place message in mailbox */
pecb->eventCounter = 1;
EventTaskToRdy(pecb); /* Check waiting list */
OsSchedUnlock();
return E_OK;
}
else /* If there is already a message in mailbox */
{
return E_MBOX_FULL; /* Mailbox is full,and return "E_MBOX_FULL" */
}
}
示例7: CoResetTaskDelayTick
/**
*******************************************************************************
* @brief Reset task delay ticks
* @param[in] ptcb Task that want to insert into DELAY list.
* @param[in] ticks Specify system tick number which will delay .
* @param[out] None
* @retval E_CALL Error call in ISR.
* @retval E_INVALID_ID Invalid task id.
* @retval E_NOT_IN_DELAY_LIST Task not in delay list.
* @retval E_OK The current task was inserted to DELAY list
* successful,it will delay for specify time.
* @par Description
* @details This function delay specify ticks for current task.
*******************************************************************************
*/
StatusType CoResetTaskDelayTick(OS_TID taskID,U32 ticks) {
P_OSTCB ptcb;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(taskID >= CFG_MAX_USER_TASKS + SYS_TASK_NUM) {
return E_INVALID_ID;
}
#endif
ptcb = &TCBTbl[taskID];
#if CFG_PAR_CHECKOUT_EN >0
if(ptcb->stkPtr == Co_NULL) {
return E_INVALID_ID;
}
#endif
if(ptcb->delayTick == INVALID_VALUE) { /* Is tick==INVALID_VALUE? */
return E_NOT_IN_DELAY_LIST; /* Yes,error return */
}
OsSchedLock(); /* Lock schedule */
RemoveDelayList(ptcb); /* Remove task from the DELAY list */
if(ticks == 0) { /* Is delay tick==0? */
InsertToTCBRdyList(ptcb); /* Insert task into the DELAY list */
} else {
InsertDelayList(ptcb,ticks); /* No,insert task into DELAY list */
}
OsSchedUnlock(); /* Unlock schedule,and call task schedule */
return E_OK; /* Return OK */
}
示例8: CoStartOS
/**
*******************************************************************************
* @brief Start multitask
* @param[in] None
* @param[out] None
* @retval None
*
* @par Description
* @details This function is called to start multitask.After it is called,
* OS start schedule task by priority or/and time slice.
* @note This function must be called to start OS when you use CoOS,and must
* call after CoOsInit().
*******************************************************************************
*/
void CoStartOS(void) {
TCBRunning = &TCBTbl[0]; /* Get running task */
TCBNext = TCBRunning; /* Set next scheduled task as running task */
TCBRunning->state = TASK_RUNNING; /* Set running task status to RUNNING */
RemoveFromTCBRdyList(TCBRunning); /* Remove running task from READY list */
OsSchedUnlock(); /* Enable Schedule,call task schedule */
}
示例9: AssignTCB
/**
*******************************************************************************
* @brief Assign a TCB to task being created
* @param[in] None
* @param[out] None
*
* @retval XXXX
*
* @par Description
* @details This function is called to assign a task control block for task
* being created.
*******************************************************************************
*/
static P_OSTCB AssignTCB(void)
{
P_OSTCB ptcb;
OsSchedLock(); /* Lock schedule */
if(FreeTCB == Co_NULL) /* Is there no free TCB */
{
OsSchedUnlock(); /* Yes,unlock schedule */
return Co_NULL; /* Error return */
}
ptcb = FreeTCB; /* Yes,assgin free TCB for this task */
/* Set next item as the head of free TCB list */
FreeTCB = FreeTCB->TCBnext;
OsSchedUnlock();
return ptcb;
}
示例10: CoAcceptSingleFlag
/**
*******************************************************************************
* @brief AcceptSingleFlag
* @param[in] id Flag ID.
* @param[out] None
* @retval E_INVALID_ID Invalid event ID.
* @retval E_FLAG_NOT_READY Flag is not in ready state.
* @retval E_OK The call was successful and your task owns the Flag.
*
* @par Description
* @details This fucntion is called to accept single flag
* @note
*******************************************************************************
*/
StatusType CoAcceptSingleFlag(OS_FlagID id)
{
P_FCB pfcb;
pfcb = &FlagCrl;
#if CFG_PAR_CHECKOUT_EN >0
if(id >= FLAG_MAX_NUM)
{
return E_INVALID_ID; /* Invalid 'id',return error */
}
if((pfcb->flagActive&(1<<id)) == 0)
{
return E_INVALID_ID; /* Flag is deactive,return error */
}
#endif
if((pfcb->flagRdy&(1<<id)) != 0) /* If the required flag is set */
{
OsSchedLock()
pfcb->flagRdy &= ~((FlagCrl.resetOpt)&(1<<id)); /* Clear the flag */
OsSchedUnlock();
return E_OK;
}
else /* If the required flag is not set */
{
return E_FLAG_NOT_READY;
}
}
示例11: CoPostSem
/**
*******************************************************************************
* @brief Post a semaphore
* @param[in] id id of event control block associated with the desired semaphore.
* @param[out] None
* @retval E_INVALID_ID Parameter id passed was invalid event ID.
* @retval E_SEM_FULL Semaphore full.
* @retval E_OK Semaphore had post successful.
*
* @par Description
* @details This function is called to post a semaphore to corresponding event.
*
* @note
*******************************************************************************
*/
StatusType CoPostSem(OS_EventID id)
{
P_ECB pecb;
#if CFG_PAR_CHECKOUT_EN >0
if(id >= CFG_MAX_EVENT)
{
return E_INVALID_ID;
}
#endif
pecb = &EventTbl[id];
#if CFG_PAR_CHECKOUT_EN >0
if(pecb->eventType != EVENT_TYPE_SEM) /* Invalid event control block type */
{
return E_INVALID_ID;
}
#endif
/* Make sure semaphore will not overflow */
if(pecb->eventCounter == pecb->initialEventCounter)
{
return E_SEM_FULL; /* The counter of Semaphore reach the max number*/
}
OsSchedLock();
pecb->eventCounter++; /* Increment semaphore count to register event */
EventTaskToRdy(pecb); /* Check semaphore event waiting list */
OsSchedUnlock();
return E_OK;
}
示例12: SysTick_Handler
/**
*******************************************************************************
* @brief System tick interrupt handler.
* @param[in] None
* @param[out] None
* @retval None
*
* @par Description
* @details This is system tick interrupt headler.
* @note CoOS may schedule when exiting this ISR.
*******************************************************************************
*/
void SysTick_Handler(void) {
OSSchedLock++; /* Lock scheduler. */
OSTickCnt++; /* Increment systerm time. */
#if CFG_TASK_WAITTING_EN >0
if(DlyList != Co_NULL) { /* Have task in delay list? */
if(DlyList->delayTick > 1) { /* Delay time > 1? */
DlyList->delayTick--; /* Decrease delay time of the list head. */
} else {
DlyList->delayTick = 0;
isr_TimeDispose(); /* Call hander for delay time list */
}
}
#endif
#if CFG_TMR_EN > 0
if(TmrList != Co_NULL) { /* Have timer in working? */
if(TmrList->tmrCnt > 1) { /* Timer time > 1? */
TmrList->tmrCnt--; /* Decrease timer time of the list head. */
} else {
TmrList->tmrCnt = 0;
isr_TmrDispose(); /* Call hander for timer list */
}
}
#endif
TaskSchedReq = Co_TRUE;
OsSchedUnlock();
}
示例13: CoGetFreeBlockNum
/**
*******************************************************************************
* @brief Get free block number in a memory partition
* @param[in] mmID Specify memory partition.
*
* @param[out] E_INVALID_ID Invalid ID was passed and get counter failure.
* @param[out] E_OK Get current counter successful.
* @retval fbNum The number of free block.
*
* @par Description
* @details This function is called to get free block number in a memory
* partition.
*******************************************************************************
*/
U32 CoGetFreeBlockNum(OS_MMID mmID,StatusType* perr)
{
U32 fbNum;
P_MM memCtl;
P_MemBlk memBlk;
#if CFG_PAR_CHECKOUT_EN >0 /* Check validity of parameter */
if(mmID >= CFG_MAX_MM)
{
*perr = E_INVALID_ID;
return 0;
}
if( ((1<<mmID)&MemoryIDVessel) == 0)
{
*perr = E_INVALID_ID; /* Invalid memory id,return 0 */
return 0;
}
#endif
memCtl = &MemoryTbl[mmID];
OsSchedLock(); /* Lock schedule */
memBlk = (P_MemBlk)(memCtl->freeBlock);/* Get the free item in memory list*/
fbNum = 0;
while(memBlk != NULL) /* Get counter of free item */
{
fbNum++;
memBlk = memBlk->nextBlock; /* Get next free iterm */
}
OsSchedUnlock(); /* Unlock schedul */
*perr = E_OK;
return fbNum; /* Return the counter of free item */
}
示例14: CoSetFlag
/**
*******************************************************************************
* @brief Set a flag
* @param[in] id Flag ID.
* @param[out] None
* @retval E_INVALID_ID Invalid event ID.
* @retval E_OK Event deleted successful.
*
* @par Description
* @details This function is called to set a flag.
* @note
*******************************************************************************
*/
StatusType CoSetFlag(OS_FlagID id)
{
P_FLAG_NODE pnode;
P_FCB pfcb;
pfcb = &FlagCrl;
#if CFG_PAR_CHECKOUT_EN >0
if(id >= FLAG_MAX_NUM) /* Flag is valid or not */
{
return E_INVALID_ID; /* Invalid flag id */
}
if((pfcb->flagActive&(1<<id)) == 0)
{
return E_INVALID_ID; /* Flag is not exist */
}
#endif
if((pfcb->flagRdy&(1<<id)) != 0) /* Flag had already been set */
{
return E_OK;
}
pfcb->flagRdy |= (1<<id); /* Update the flags ready list */
OsSchedLock();
pnode = pfcb->headNode;
while(pnode != Co_NULL)
{
if(pnode->waitType == OPT_WAIT_ALL) /* Extract all the bits we want */
{
if((pnode->waitFlags&pfcb->flagRdy) == pnode->waitFlags)
{
/* Remove the flag node from the wait list */
pnode = RemoveFromLink(pnode);
if((pfcb->resetOpt&(1<<id)) != 0)/* If the flags is auto-reset*/
{
break;
}
continue;
}
}
else /* Extract only the bits we want */
{
if( (pnode->waitFlags & pfcb->flagRdy) != 0)
{
/* Remove the flag node from the wait list */
pnode = RemoveFromLink(pnode);
if((pfcb->resetOpt&(1<<id)) != 0)
{
break; /* The flags is auto-reset */
}
continue;
}
}
pnode = pnode->nextNode;
}
OsSchedUnlock();
return E_OK;
}
示例15: ReleaseECB
/**
*******************************************************************************
* @brief Release a ECB
* @param[in] pecb A pointer to event control block which be released.
* @param[out] None
* @retval None
*
* @par Description
* @details This function is called to release a event control block when a
* event be deleted.
*******************************************************************************
*/
static void ReleaseECB(P_ECB pecb)
{
pecb->eventType = EVENT_TYPE_INVALID; /* Sign that not to use. */
OsSchedLock(); /* Lock schedule */
pecb->eventPtr = FreeEventList; /* Release ECB that event hold */
FreeEventList = pecb; /* Reset free event item */
OsSchedUnlock(); /* Unlock schedule */
}