Update v0.10 remove OSWaitTime[]
[sudos/9s12.git] / sources / ucos / os_sem.c
blobf67edde84d5f98e58180f430d22e24839543a9b3
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * SEMAPHORE MANAGEMENT
7 * (c) Copyright 1992-2007, Micrium, Weston, FL
8 * All Rights Reserved
10 * File : OS_SEM.C
11 * By : Jean J. Labrosse
12 * Version : V2.86
14 * LICENSING TERMS:
15 * ---------------
16 * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
17 * If you plan on using uC/OS-II in a commercial product you need to contact Micriµm to properly license
18 * its use in your product. We provide ALL the source code for your convenience and to help you experience
19 * uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a
20 * licensing fee.
21 *********************************************************************************************************
24 #ifndef OS_MASTER_FILE
25 #include <ucos_ii.h>
26 #endif
28 #if OS_SEM_EN > 0
29 /*$PAGE*/\f
31 *********************************************************************************************************
32 * ACCEPT SEMAPHORE
34 * Description: This function checks the semaphore to see if a resource is available or, if an event
35 * occurred. Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
36 * resource is not available or the event did not occur.
38 * Arguments : pevent is a pointer to the event control block
40 * Returns : > 0 if the resource is available or the event did not occur the semaphore is
41 * decremented to obtain the resource.
42 * == 0 if the resource is not available or the event did not occur or,
43 * if 'pevent' is a NULL pointer or,
44 * if you didn't pass a pointer to a semaphore
45 *********************************************************************************************************
48 #if OS_SEM_ACCEPT_EN > 0
49 INT16U OSSemAccept (OS_EVENT *pevent)
51 INT16U cnt;
52 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
53 OS_CPU_SR cpu_sr = 0;
54 #endif
58 #if OS_ARG_CHK_EN > 0
59 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
60 return (0);
62 #endif
63 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
64 return (0);
66 OS_ENTER_CRITICAL();
67 cnt = pevent->OSEventCnt;
68 if (cnt > 0) { /* See if resource is available */
69 pevent->OSEventCnt--; /* Yes, decrement semaphore and notify caller */
71 OS_EXIT_CRITICAL();
72 return (cnt); /* Return semaphore count */
74 #endif
76 /*$PAGE*/\f
78 *********************************************************************************************************
79 * CREATE A SEMAPHORE
81 * Description: This function creates a semaphore.
83 * Arguments : cnt is the initial value for the semaphore. If the value is 0, no resource is
84 * available (or no event has occurred). You initialize the semaphore to a
85 * non-zero value to specify how many resources are available (e.g. if you have
86 * 10 resources, you would initialize the semaphore to 10).
88 * Returns : != (void *)0 is a pointer to the event control block (OS_EVENT) associated with the
89 * created semaphore
90 * == (void *)0 if no event control blocks were available
91 *********************************************************************************************************
94 OS_EVENT *OSSemCreate (INT16U cnt)
96 OS_EVENT *pevent;
97 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
98 OS_CPU_SR cpu_sr = 0;
99 #endif
103 if (OSIntNesting > 0) { /* See if called from ISR ... */
104 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
106 OS_ENTER_CRITICAL();
107 pevent = OSEventFreeList; /* Get next free event control block */
108 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
109 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
111 OS_EXIT_CRITICAL();
112 if (pevent != (OS_EVENT *)0) { /* Get an event control block */
113 pevent->OSEventType = OS_EVENT_TYPE_SEM;
114 pevent->OSEventCnt = cnt; /* Set semaphore value */
115 pevent->OSEventPtr = (void *)0; /* Unlink from ECB free list */
116 #if OS_EVENT_NAME_SIZE > 1
117 pevent->OSEventName[0] = '?'; /* Unknown name */
118 pevent->OSEventName[1] = OS_ASCII_NUL;
119 #endif
120 OS_EventWaitListInit(pevent); /* Initialize to 'nobody waiting' on sem. */
122 return (pevent);
125 /*$PAGE*/\f
127 *********************************************************************************************************
128 * DELETE A SEMAPHORE
130 * Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
132 * Arguments : pevent is a pointer to the event control block associated with the desired
133 * semaphore.
135 * opt determines delete options as follows:
136 * opt == OS_DEL_NO_PEND Delete semaphore ONLY if no task pending
137 * opt == OS_DEL_ALWAYS Deletes the semaphore even if tasks are waiting.
138 * In this case, all the tasks pending will be readied.
140 * perr is a pointer to an error code that can contain one of the following values:
141 * OS_ERR_NONE The call was successful and the semaphore was deleted
142 * OS_ERR_DEL_ISR If you attempted to delete the semaphore from an ISR
143 * OS_ERR_INVALID_OPT An invalid option was specified
144 * OS_ERR_TASK_WAITING One or more tasks were waiting on the semaphore
145 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore
146 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
148 * Returns : pevent upon error
149 * (OS_EVENT *)0 if the semaphore was successfully deleted.
151 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
152 * the semaphore MUST check the return code of OSSemPend().
153 * 2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
154 * they check 'pevent' to see that it's a NULL pointer.
155 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
156 * time is directly proportional to the number of tasks waiting on the semaphore.
157 * 4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
158 * applications where the semaphore is used for mutual exclusion because the resource(s)
159 * will no longer be guarded by the semaphore.
160 *********************************************************************************************************
163 #if OS_SEM_DEL_EN > 0
164 OS_EVENT *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *perr)
166 BOOLEAN tasks_waiting;
167 OS_EVENT *pevent_return;
168 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
169 OS_CPU_SR cpu_sr = 0;
170 #endif
174 #if OS_ARG_CHK_EN > 0
175 if (perr == (INT8U *)0) { /* Validate 'perr' */
176 return (pevent);
178 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
179 *perr = OS_ERR_PEVENT_NULL;
180 return (pevent);
182 #endif
183 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
184 *perr = OS_ERR_EVENT_TYPE;
185 return (pevent);
187 if (OSIntNesting > 0) { /* See if called from ISR ... */
188 *perr = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
189 return (pevent);
191 OS_ENTER_CRITICAL();
192 if (pevent->OSEventGrp != 0) { /* See if any tasks waiting on semaphore */
193 tasks_waiting = OS_TRUE; /* Yes */
194 } else {
195 tasks_waiting = OS_FALSE; /* No */
197 switch (opt) {
198 case OS_DEL_NO_PEND: /* Delete semaphore only if no task waiting */
199 if (tasks_waiting == OS_FALSE) {
200 #if OS_EVENT_NAME_SIZE > 1
201 pevent->OSEventName[0] = '?'; /* Unknown name */
202 pevent->OSEventName[1] = OS_ASCII_NUL;
203 #endif
204 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
205 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
206 pevent->OSEventCnt = 0;
207 OSEventFreeList = pevent; /* Get next free event control block */
208 OS_EXIT_CRITICAL();
209 *perr = OS_ERR_NONE;
210 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
211 } else {
212 OS_EXIT_CRITICAL();
213 *perr = OS_ERR_TASK_WAITING;
214 pevent_return = pevent;
216 break;
218 case OS_DEL_ALWAYS: /* Always delete the semaphore */
219 while (pevent->OSEventGrp != 0) { /* Ready ALL tasks waiting for semaphore */
220 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
222 #if OS_EVENT_NAME_SIZE > 1
223 pevent->OSEventName[0] = '?'; /* Unknown name */
224 pevent->OSEventName[1] = OS_ASCII_NUL;
225 #endif
226 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
227 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
228 pevent->OSEventCnt = 0;
229 OSEventFreeList = pevent; /* Get next free event control block */
230 OS_EXIT_CRITICAL();
231 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
232 OS_Sched(); /* Find highest priority task ready to run */
234 *perr = OS_ERR_NONE;
235 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
236 break;
238 default:
239 OS_EXIT_CRITICAL();
240 *perr = OS_ERR_INVALID_OPT;
241 pevent_return = pevent;
242 break;
244 return (pevent_return);
246 #endif
248 /*$PAGE*/\f
250 *********************************************************************************************************
251 * PEND ON SEMAPHORE
253 * Description: This function waits for a semaphore.
255 * Arguments : pevent is a pointer to the event control block associated with the desired
256 * semaphore.
258 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
259 * wait for the resource up to the amount of time specified by this argument.
260 * If you specify 0, however, your task will wait forever at the specified
261 * semaphore or, until the resource becomes available (or the event occurs).
263 * perr is a pointer to where an error message will be deposited. Possible error
264 * messages are:
266 * OS_ERR_NONE The call was successful and your task owns the resource
267 * or, the event you are waiting for occurred.
268 * OS_ERR_TIMEOUT The semaphore was not received within the specified
269 * 'timeout'.
270 * OS_ERR_PEND_ABORT The wait on the semaphore was aborted.
271 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
272 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
273 * would lead to a suspension.
274 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
275 * OS_ERR_PEND_LOCKED If you called this function when the scheduler is locked
277 * Returns : none
278 *********************************************************************************************************
280 /*$PAGE*/\f
281 void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
283 INT8U y; // add by wakeup
284 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
285 OS_CPU_SR cpu_sr = 0;
286 #endif
288 timeout = timeout + OSTime; // timeout is the right time to wakeup
290 #if OS_ARG_CHK_EN > 0
291 if (perr == (INT8U *)0) { /* Validate 'perr' */
292 return;
294 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
295 *perr = OS_ERR_PEVENT_NULL;
296 return;
298 #endif
299 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
300 *perr = OS_ERR_EVENT_TYPE;
301 return;
303 if (OSIntNesting > 0) { /* See if called from ISR ... */
304 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
305 return;
307 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
308 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
309 return;
311 OS_ENTER_CRITICAL();
312 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
313 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
314 OS_EXIT_CRITICAL();
315 *perr = OS_ERR_NONE;
316 return;
318 /* Otherwise, must wait until event occurs */
319 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
320 OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK;
321 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
322 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
323 OS_EXIT_CRITICAL();
324 OS_Sched(); /* Find next highest priority task ready */
325 OS_ENTER_CRITICAL();
326 switch (OSTCBCur->OSTCBStatPend) { /* See if we timed-out or aborted */
327 case OS_STAT_PEND_OK:
328 *perr = OS_ERR_NONE;
329 break;
331 case OS_STAT_PEND_ABORT:
332 *perr = OS_ERR_PEND_ABORT; /* Indicate that we aborted */
333 break;
335 case OS_STAT_PEND_TO:
336 default:
337 OS_EventTaskRemove(OSTCBCur, pevent);
338 *perr = OS_ERR_TIMEOUT; /* Indicate that we didn't get event within TO */
339 break;
341 OSTCBCur->OSTCBStat = OS_STAT_RDY; /* Set task status to ready */
342 OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK; /* Clear pend status */
343 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* Clear event pointers */
344 #if (OS_EVENT_MULTI_EN > 0)
345 OSTCBCur->OSTCBEventMultiPtr = (OS_EVENT **)0;
346 #endif
347 if(timeout < OSNextUp) OSNextUp = timeout;
348 OS_EXIT_CRITICAL();
351 /*$PAGE*/\f
353 *********************************************************************************************************
354 * ABORT WAITING ON A SEMAPHORE
356 * Description: This function aborts & readies any tasks currently waiting on a semaphore. This function
357 * should be used to fault-abort the wait on the semaphore, rather than to normally signal
358 * the semaphore via OSSemPost().
360 * Arguments : pevent is a pointer to the event control block associated with the desired
361 * semaphore.
363 * opt determines the type of ABORT performed:
364 * OS_PEND_OPT_NONE ABORT wait for a single task (HPT) waiting on the
365 * semaphore
366 * OS_PEND_OPT_BROADCAST ABORT wait for ALL tasks that are waiting on the
367 * semaphore
369 * perr is a pointer to where an error message will be deposited. Possible error
370 * messages are:
372 * OS_ERR_NONE No tasks were waiting on the semaphore.
373 * OS_ERR_PEND_ABORT At least one task waiting on the semaphore was readied
374 * and informed of the aborted wait; check return value
375 * for the number of tasks whose wait on the semaphore
376 * was aborted.
377 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
378 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
380 * Returns : == 0 if no tasks were waiting on the semaphore, or upon error.
381 * > 0 if one or more tasks waiting on the semaphore are now readied and informed.
382 *********************************************************************************************************
385 #if OS_SEM_PEND_ABORT_EN > 0
386 INT8U OSSemPendAbort (OS_EVENT *pevent, INT8U opt, INT8U *perr)
388 INT8U nbr_tasks;
389 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
390 OS_CPU_SR cpu_sr = 0;
391 #endif
395 #if OS_ARG_CHK_EN > 0
396 if (perr == (INT8U *)0) { /* Validate 'perr' */
397 return (0);
399 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
400 *perr = OS_ERR_PEVENT_NULL;
401 return (0);
403 #endif
404 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
405 *perr = OS_ERR_EVENT_TYPE;
406 return (0);
408 OS_ENTER_CRITICAL();
409 if (pevent->OSEventGrp != 0) { /* See if any task waiting on semaphore? */
410 nbr_tasks = 0;
411 switch (opt) {
412 case OS_PEND_OPT_BROADCAST: /* Do we need to abort ALL waiting tasks? */
413 while (pevent->OSEventGrp != 0) { /* Yes, ready ALL tasks waiting on semaphore */
414 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_ABORT);
415 nbr_tasks++;
417 break;
419 case OS_PEND_OPT_NONE:
420 default: /* No, ready HPT waiting on semaphore */
421 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_ABORT);
422 nbr_tasks++;
423 break;
425 OS_EXIT_CRITICAL();
426 OS_Sched(); /* Find HPT ready to run */
427 *perr = OS_ERR_PEND_ABORT;
428 return (nbr_tasks);
430 OS_EXIT_CRITICAL();
431 *perr = OS_ERR_NONE;
432 return (0); /* No tasks waiting on semaphore */
434 #endif
436 /*$PAGE*/\f
438 *********************************************************************************************************
439 * POST TO A SEMAPHORE
441 * Description: This function signals a semaphore
443 * Arguments : pevent is a pointer to the event control block associated with the desired
444 * semaphore.
446 * Returns : OS_ERR_NONE The call was successful and the semaphore was signaled.
447 * OS_ERR_SEM_OVF If the semaphore count exceeded its limit. In other words, you have
448 * signalled the semaphore more often than you waited on it with either
449 * OSSemAccept() or OSSemPend().
450 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore
451 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
452 *********************************************************************************************************
455 INT8U OSSemPost (OS_EVENT *pevent)
457 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
458 OS_CPU_SR cpu_sr = 0;
459 #endif
463 #if OS_ARG_CHK_EN > 0
464 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
465 return (OS_ERR_PEVENT_NULL);
467 #endif
468 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
469 return (OS_ERR_EVENT_TYPE);
471 OS_ENTER_CRITICAL();
472 if (pevent->OSEventGrp != 0) { /* See if any task waiting for semaphore */
473 /* Ready HPT waiting on event */
474 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
475 OS_EXIT_CRITICAL();
476 OS_Sched(); /* Find HPT ready to run */
477 return (OS_ERR_NONE);
479 if (pevent->OSEventCnt < 65535u) { /* Make sure semaphore will not overflow */
480 pevent->OSEventCnt++; /* Increment semaphore count to register event */
481 OS_EXIT_CRITICAL();
482 return (OS_ERR_NONE);
484 OS_EXIT_CRITICAL(); /* Semaphore value has reached its maximum */
485 return (OS_ERR_SEM_OVF);
488 /*$PAGE*/\f
490 *********************************************************************************************************
491 * QUERY A SEMAPHORE
493 * Description: This function obtains information about a semaphore
495 * Arguments : pevent is a pointer to the event control block associated with the desired
496 * semaphore
498 * p_sem_data is a pointer to a structure that will contain information about the
499 * semaphore.
501 * Returns : OS_ERR_NONE The call was successful and the message was sent
502 * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non semaphore.
503 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
504 * OS_ERR_PDATA_NULL If 'p_sem_data' is a NULL pointer
505 *********************************************************************************************************
508 #if OS_SEM_QUERY_EN > 0
509 INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *p_sem_data)
511 #if OS_LOWEST_PRIO <= 63
512 INT8U *psrc;
513 INT8U *pdest;
514 #else
515 INT16U *psrc;
516 INT16U *pdest;
517 #endif
518 INT8U i;
519 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
520 OS_CPU_SR cpu_sr = 0;
521 #endif
525 #if OS_ARG_CHK_EN > 0
526 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
527 return (OS_ERR_PEVENT_NULL);
529 if (p_sem_data == (OS_SEM_DATA *)0) { /* Validate 'p_sem_data' */
530 return (OS_ERR_PDATA_NULL);
532 #endif
533 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
534 return (OS_ERR_EVENT_TYPE);
536 OS_ENTER_CRITICAL();
537 p_sem_data->OSEventGrp = pevent->OSEventGrp; /* Copy message mailbox wait list */
538 psrc = &pevent->OSEventTbl[0];
539 pdest = &p_sem_data->OSEventTbl[0];
540 for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
541 *pdest++ = *psrc++;
543 p_sem_data->OSCnt = pevent->OSEventCnt; /* Get semaphore count */
544 OS_EXIT_CRITICAL();
545 return (OS_ERR_NONE);
547 #endif /* OS_SEM_QUERY_EN */
549 /*$PAGE*/\f
551 *********************************************************************************************************
552 * SET SEMAPHORE
554 * Description: This function sets the semaphore count to the value specified as an argument. Typically,
555 * this value would be 0.
557 * You would typically use this function when a semaphore is used as a signaling mechanism
558 * and, you want to reset the count value.
560 * Arguments : pevent is a pointer to the event control block
562 * cnt is the new value for the semaphore count. You would pass 0 to reset the
563 * semaphore count.
565 * perr is a pointer to an error code returned by the function as follows:
567 * OS_ERR_NONE The call was successful and the semaphore value was set.
568 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
569 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
570 * OS_ERR_TASK_WAITING If tasks are waiting on the semaphore.
571 *********************************************************************************************************
574 #if OS_SEM_SET_EN > 0
575 void OSSemSet (OS_EVENT *pevent, INT16U cnt, INT8U *perr)
577 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
578 OS_CPU_SR cpu_sr = 0;
579 #endif
583 #if OS_ARG_CHK_EN > 0
584 if (perr == (INT8U *)0) { /* Validate 'perr' */
585 return;
587 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
588 *perr = OS_ERR_PEVENT_NULL;
589 return;
591 #endif
592 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
593 *perr = OS_ERR_EVENT_TYPE;
594 return;
596 OS_ENTER_CRITICAL();
597 *perr = OS_ERR_NONE;
598 if (pevent->OSEventCnt > 0) { /* See if semaphore already has a count */
599 pevent->OSEventCnt = cnt; /* Yes, set it to the new value specified. */
600 } else { /* No */
601 if (pevent->OSEventGrp == 0) { /* See if task(s) waiting? */
602 pevent->OSEventCnt = cnt; /* No, OK to set the value */
603 } else {
604 *perr = OS_ERR_TASK_WAITING;
607 OS_EXIT_CRITICAL();
609 #endif
611 #endif /* OS_SEM_EN */