.NamePtr
This is a pointer to an ASCII string used to provide a name to the mutual exclusion semaphore. The ASCII string can have any length as long as it is NUL
terminated.
.PendList.NbrEntries
Each mutual exclusion semaphore contains a list of tasks waiting for the semaphore to be released. The variable represents the number of entries in the wait list.
.OwnerOriginalPrio
This variable holds the original priority of the task that owns the mutual exclusion semaphore.
.OwnerTCBPtr->Prio
Dereferencing the pointer to the OS_TCB
of the mutual exclusion semaphore owner allows the application to determine whether a task priority was changed.
.OwnerNestingCtr
This variable indicates how many times the owner of the mutual exclusion semaphore requested the semaphore.
.TS
...
Include Page |
---|
| css.Migrating from uC-OS-II to uC-OS-III.css |
---|
| css.Migrating from uC-OS-II to uC-OS-III.css |
---|
|
Include Page |
---|
| css.webworks.css |
---|
| css.webworks.css |
---|
|
Mutual Exclusion Semaphores Table C-11 shows the difference in API for mutual exclusion semaphore management. HTML Table |
---|
|
Table Row (tr) |
---|
Table Cell (td) |
---|
µC/OS-II (os_mutex.c) |
Table Cell (td) |
---|
µC/OS-III (os_mutex.c) |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| BOOLEAN OSMutexAccept( OS_EVENT *pevent, INT8U *perr); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| OS_EVENT * OSMutexCreate( INT8U prio, INT8U *perr); |
Table Cell (td) |
---|
| void OSMutexCreate( OS_MUTEX *p_mutex, CPU_CHAR *p_name, OS_ERR *p_err); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| OS_EVENT * OSMutexDel( OS_EVENT *pevent, INT8U opt, INT8U *perr); |
Table Cell (td) |
---|
| void OSMutexDel( OS_MUTEX *p_mutex, OS_OPT opt, OS_ERR *p_err); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| void OSMutexPend( OS_EVENT *pevent, INT32U timeout, INT8U *perr); |
Table Cell (td) |
---|
| void OSMutexPend( OS_MUTEX *p_mutex, OS_TICK timeout, OS_OPT opt, CPU_TS *p_ts, OS_ERR *p_err); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
OS_OBJ_QTY OSMutexPendAbort( OS_MUTEX *p_mutex, OS_OPT opt, OS_ERR *p_err); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| INT8U OSMutexPost( OS_EVENT *pevent); |
Table Cell (td) |
---|
| void OSMutexPost( OS_MUTEX *p_mutex, OS_OPT opt, OS_ERR *p_err); |
|
Table Row (tr) |
---|
Table Cell (td) |
---|
| INT8U OSMutexQuery( OS_EVENT *pevent, OS_MUTEX_DATA *p_mutex_data); |
|
|
- Mutual Exclusion Semaphore Management API
- In µC/OS-III, there is no “accept” API, since this feature is built into the OSMutexPend() by specifying the OS_OPT_PEND_NON_BLOCKING option.
- In µC/OS-II, OSMutexCreate() returns the address of an OS_EVENT, which is used as the “handle” to the message mailbox. In µC/OS-III, the application must allocate storage for an OS_MUTEX, which serves the same purpose as the OS_EVENT. The benefit in µC/OS-III is that it is not necessary to predetermine the number of mutual-exclusion semaphores at compile time.
- µC/OS-III returns additional information when a mutex is released. The releaser takes a snapshot of the current time stamp and stores it in the OS_MUTEX. The new owner of the mutex therefore knows when the mutex was released.
- µC/OS-III does not provide query services as they were rarely used.