Techniques for allowing exclusive access
Last updated
Last updated
Possible synchronization approaches:
Disable Interrupts
disable()/enable() or cli()/sti()
Inhibit preemption
no preemp()/preempt()
Locks or atomic
lock()/unlock()
Use of semaphores
Counter + task list.
P()/V (), wait()/signal(), take()/give(), ...
All other system activities are blocked, not just other tasks, but also interrupt service routines, including the system tick handler.
Very easy to implement but should only be used with very short critical regions (e.g. access to a few HW registers, read-modify-write of a variable).
Each task can only be blocked once and for the maximum duration of the critical region of lower priority tasks (or smaller relative deadline for EDF), even if they don’t use any shared resource!!
All other tasks are blocked. However, contrarily to disabling the interrupts, in this case the interrupt service routines , including the system tick, are not blocked !
Very easy to implement but not efficient, as it causes unnecessary blocking.
Each task can only be blocked once and for the maximum duration of the critical region of lower priority tasks (or smaller relative deadline for EDF), even if these don’t use any shared resource!!
More complex and costly to implement.
In general much more efficient resource management.
However, the blocking duration depends on the specific protocol used to manage the semaphores.
These protocols should prevent:
Indeterminate blocking.
Chain blocking.
Deadlocks.