An interrupt service routine has received a byte and must hand it to a task for processing. The ISR must not block. Which action is correct?
- (A)
The ISR takes a mutex, copies the byte and unlocks the mutex.
- (B)
The ISR gives a binary semaphore on which the task is waiting.
- (C)
The ISR waits until the task has finished processing the byte.
- (D)
The ISR locks the mutex and leaves the task to unlock it.
Answer and solution
Answer: (B)
An ISR must not block, so it cannot wait for a mutex that a task may hold. That rules out A and D.
Waiting for the task to finish is also blocking, so C is wrong.
Giving a binary semaphore never blocks. It readies the waiting task, which then processes the byte. The answer is B.