§ Semaphores
1.overview
Binary Semaphores: synchronization
Application, and release is performed by different tasks. Caveat: if The Event Repeats Too Quickly, Information May Be Lost.
Mutual Exclusion Semaphores: MUTUAL EXCLUSION
Have the concept of Owner. Application and release is performed by the same task (OWNER). A task can be applied for multiple times. Only Owner can be released.
Counting semaphores
2.More About Mutual Exclusion SemaphoRes
Deletion Safety (Owner EXISTS)
The Deletion Safety Option Prevents a Task from Being Deleted While It Owns The Semaphore. SEM_DELETE_SAFE OPTIONS STATUS TASKDELETEFORCE (TID)
Unbounded Priority Inversion
Problem exissrs priority inheritance algorithm Solves The Unbounded Priority Inversion Problem. Enabled on Mutex Semaphores by Specifying The Sem_INVersion_safe Option During Semmcreate ().
Program suggestion
Writing the library function of accessing resources Using muters in library functions users only access resources through library functions
Deadlock Problem
Problem description
Solutions: 1) Use only one semaphore protection resource, 2) All tasks access resources in the same order
Other considerations
Can't be used in ISR; Critical Region is as short as possible;
LOCKING OUT preemption
.
ISR's and mutual Exclusion (ISR vs. task)
ISR's can't use mutex semaphores. TO Disable / Re-Enable Interrupts: int inlock (), Void Intunlock (LOCKKEY), VOID INTUNLOCK (LOCKKEY)