Skip to content

Commit af689aa

Browse files
Mathieu Choplainnashif
authored andcommitted
kernel: irq: update irq_lock() documentation regarding context switches
Upon context switch, the virtual "interrupt lock" acquired by irq_lock() must not be "held". However, the current documentation for irq_lock() says that it is perfectly valid to hold it (!), and that a suspended thread will hold the "interrupt lock" upon being scheduled again (!!). Update the documentation to remove the outdated section and indicate that context switching while holding the interrupt lock is not allowed. Signed-off-by: Mathieu Choplain <[email protected]>
1 parent 5183fc5 commit af689aa

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

include/zephyr/irq.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,13 @@ irq_disconnect_dynamic(unsigned int irq, unsigned int priority,
239239
* (for example, ARM) will fail silently if invoked from user mode instead
240240
* of generating an exception.
241241
*
242-
* @note
243-
* This routine can be called by ISRs or by threads. If it is called by a
244-
* thread, the interrupt lock is thread-specific; this means that interrupts
245-
* remain disabled only while the thread is running. If the thread performs an
246-
* operation that allows another thread to run (for example, giving a semaphore
247-
* or sleeping for N milliseconds), the interrupt lock no longer applies and
248-
* interrupts may be re-enabled while other processing occurs. When the thread
249-
* once again becomes the current thread, the kernel re-establishes its
250-
* interrupt lock; this ensures the thread won't be interrupted until it has
251-
* explicitly released the interrupt lock it established.
242+
* This routine can be called by ISRs and threads.
243+
*
244+
* @warning
245+
* As long as all recursive calls to irq_lock() have not been balanced with
246+
* corresponding irq_unlock() calls, the caller "holds the interrupt lock".
247+
*
248+
* "Holding the interrupt lock" when a context switch occurs is illegal.
252249
*
253250
* @warning
254251
* The lock-out key should never be used to manually re-enable interrupts

0 commit comments

Comments
 (0)