Skip to content

Commit c42eb82

Browse files
pabigotnashif
authored andcommitted
doc: kernel: interrupts: correct description of irq lock behavior
Contrary to the documentation giving a semaphore while an IRQ lock is held does not release the lock and give control to another thread. The release-lock behavior is observed only if the lock-holding thread sleeps. However the opportunity to reschedule will have been lost so it may be necessary to explicitly yield to allow the higher-priority thread to be serviced. Signed-off-by: Peter Bigot <[email protected]>
1 parent d83647d commit c42eb82

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

doc/reference/kernel/other/interrupts.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,26 @@ is running.
134134

135135
.. important::
136136
The IRQ lock is thread-specific. If thread A locks out interrupts
137-
then performs an operation that allows thread B to run
138-
(e.g. giving a semaphore or sleeping for N milliseconds), the thread's
139-
IRQ lock no longer applies once thread A is swapped out. This means
140-
that interrupts can be processed while thread B is running unless
141-
thread B has also locked out interrupts using its own IRQ lock.
142-
(Whether interrupts can be processed while the kernel is switching
143-
between two threads that are using the IRQ lock is architecture-specific.)
137+
then performs an operation that puts itself to sleep (e.g. sleeping
138+
for N milliseconds), the thread's IRQ lock no longer applies once
139+
thread A is swapped out and the next ready thread B starts to
140+
run.
141+
142+
This means that interrupts can be processed while thread B is
143+
running unless thread B has also locked out interrupts using its own
144+
IRQ lock. (Whether interrupts can be processed while the kernel is
145+
switching between two threads that are using the IRQ lock is
146+
architecture-specific.)
144147

145148
When thread A eventually becomes the current thread once again, the kernel
146149
re-establishes thread A's IRQ lock. This ensures thread A won't be
147150
interrupted until it has explicitly unlocked its IRQ lock.
148151

152+
If thread A does not sleep but does make a higher-priority thread B
153+
ready, the IRQ lock will inhibit any preemption that would otherwise
154+
occur. Thread B will not run until the next :ref:`reschedule point
155+
<scheduling_v2>` reached after releasing the IRQ lock.
156+
149157
Alternatively, a thread may temporarily **disable** a specified IRQ
150158
so its associated ISR does not execute when the IRQ is signaled.
151159
The IRQ must be subsequently **enabled** to permit the ISR to execute.

0 commit comments

Comments
 (0)