Книга: Real-Time Concepts for Embedded Systems
15.4.1 Interrupt Locks
15.4.1 Interrupt Locks
Interrupt locking (disabling system interrupts) is the method used to synchronize exclusive access to shared resources between tasks and ISRs. Some processor architecture designs allow for a fine-grained, interrupt-level lock, i.e., an interrupt lock level is specified so that asynchronous events at or below the level of the disabled interrupt are blocked for the duration of the lock. Other processor architecture designs allow only coarse-grained locking, i.e., all system interrupts are disabled.
When interrupts are disabled at certain levels, even the kernel scheduler cannot run because the system becomes non-responsive to those external events that can trigger task re-scheduling. This process guarantees that the current task continues to execute until it voluntarily relinquishes control. As such, interrupt locking can also be used to synchronize access to shared resources between tasks.
Interrupt locking is simple to implement and involves only a few instructions. However, frequent use of interrupt locks can alter overall system timing, with side effects including missed external events (resulting in data overflow) and clock drift (resulting in missed deadlines). Interrupt locks, although the most powerful and the most effective synchronization method, can introduce indeterminism into the system when used indiscriminately. Therefore, the duration of interrupt locks should be short, and interrupt locks should be used only when necessary to guard a task-level critical region from interrupt activities.
A task that enabled interrupt locking must avoid blocking. The behavior of a task making a blocking call (such as acquiring a semaphore in blocking mode) while interrupts are disabled is dependent on the RTOS implementation. Some RTOSes block the calling task and then re-enable the system interrupts. The kernel disables interrupts again on behalf of the task after the task is ready to be unblocked. The system can hang forever in RTOSes that do not support this feature.
- 15.4.2 Preemption Locks
- 3.1.1. Logical Clocks
- Chapter 10: Exceptions and Interrupts
- 10.3 Applications of Exceptions and Interrupts
- 10.4 A Closer Look at Exceptions and Interrupts
- The badblocks Command
- 3.1.4. Use of Synchronized Clocks
- 17.4.5. Interrupt Off Timing
- 17.4.6. Interrupt Off History
- 1.3.6 Interrupts
- 2.1.12 Interrupts
- PROJECT 6.7 — Two-Digit Multiplexed 7-Segment LED Counter with Timer Interrupt