Techniques for allowing exclusive access

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(), ...

Interrupt inhibit

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!!

Preemption inhibiting

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!!

Semaphores

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.

Last updated