Why spinlocks are used in interrupt handlers

后端 未结 3 1264
孤街浪徒
孤街浪徒 2021-01-05 01:12

I would like to know why spin locks are used instead of semaphores inside an interrupt handler.

3条回答
  •  庸人自扰
    2021-01-05 02:15

    Semaphores cause tasks to sleep on contention, which is unacceptable for interrupt handlers. Basically, for such a short and fast task (interrupt handling) the work carried out by the semaphore is overkill. Also, spinlocks can't be held by more than one task.

提交回复
热议问题