新手上路
- 积分
- 40
- 金钱
- 40
- 注册时间
- 2018-3-3
- 在线时间
- 7 小时
|
楼主 |
发表于 2018-3-28 20:11:48
|
显示全部楼层
这是*OSSemCreate (INT16U cnt)的源代码
OS_EVENT *OSSemCreate (INT16U cnt)
{
OS_EVENT *pevent;
#if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0u;
#endif
#ifdef OS_SAFETY_CRITICAL_IEC61508
if (OSSafetyCriticalStartFlag == OS_TRUE) {
OS_SAFETY_CRITICAL_EXCEPTION();
}
#endif
if (OSIntNesting > 0u) { /* See if called from ISR ... */
return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
}
OS_ENTER_CRITICAL();
pevent = OSEventFreeList; /* Get next free event control block */
if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
}
OS_EXIT_CRITICAL();
if (pevent != (OS_EVENT *)0) { /* Get an event control block */
pevent->OSEventType = OS_EVENT_TYPE_SEM; //éèÖÃÎaDÅoÅá¿
pevent->OSEventCnt = cnt; /*éèÖüÆêyÆ÷3õÖμ Set semaphore value */
pevent->OSEventPtr = (void *)0; /*éèÖÿÕÖ¸ÕëUnlink from ECB free list */
#if OS_EVENT_NAME_EN > 0u
pevent->OSEventName = (INT8U *)(void *)"?";
#endif
OS_EventWaitListInit(pevent); /*3õê¼»ˉê¼t¿ØÖÆ¿éInitialize to 'nobody waiting' on sem. */
}
return (pevent);
} |
|