Queries on sleeping and scheduling in interrupt-context

From: Ajay Garg
Date: Mon Dec 11 2023 - 07:23:51 EST


Hi everyone.

I am not 100% sure about some of the best practices while writing code
in interrupt-context.
Will be grateful to have confirmation of my thoughts from the experts :)

For all the queries, we assume that there are no thread-affinities to
any processor.
Also, we assume there are no locking/synchronisation worries as of now.


1.
A thread in interrupt-context is not schedulable.
Is this a mandate that is true under all conditions?

2.
Assuming the answer to 1. is yes :

On uniprocessor systems, code in interrupt-context *must never*
sleep/spin to wait (since the current thread cannot be scheduled,
which means that no other thread can get scheduled on the singular
processor, which means that the condition will never become true).

Is my understanding correct?

3.
Assuming the answer to 1. is yes :

On multiprocessor systems, code in interrupt-context *can* sleep/spin
to wait (since another thread can get scheduled on a different
processor, and the condition can then become true, and the current
thread can then come out of sleeping/spinning/waiting).

Is my understanding correct?


Once again, many thanks in advance for all the help.


Thanks and Regards,
Ajay