Machine-translated by Google. Questions are authored in English.
Top

Discussion

A spinlock is preferred to a mutex in kernel code when the critical section

  • A.is entered once at initialisation only
  • B.is short and may be entered from interrupt context
  • C.is long and may need to sleep
  • D.protects data that is used by one process only

Answer: B

Correct answer: is short and may be entered from interrupt context

A spinlock busy-waits, so it wastes processor time and is worth using only for a short section; and unlike a mutex it can be taken in interrupt context, where sleeping is impossible. Where the section is long or may sleep, a mutex is correct and a spinlock would be a serious fault.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.