Why spinlocks are used in interrupt handlers

后端 未结 3 1270
孤街浪徒
孤街浪徒 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 01:56

    The problem is that interrupt handlers (IH) are triggered asynchronously and in unpredictable way, out of the scope of any other activities running in the system. In fact, IHs run out of the scope of concept of the threads and scheduling at all. Due to this all mutual exclusion primitives which rely to the scheduler are unacceptable. Because they usage in the IH can dramatically increases the interrupt handling latencies (in case of IH running in the context of low priority thread) and is able to produce deadlocks (in case of IH running in the context of thread which hold the lock).

    You can look at nice and detailed description of spinlocks at http://www.makelinux.net/ldd3/chp-5-sect-5.

提交回复
热议问题