板友好 想請教一下
中央有一題問說:
為何spinlocks不適用於single-processor系統
而是常使用於multiprocessor系統
我去google了一下有goo到答案 題目一模一樣!? 如下
Q:Why spinlocks are not appropriate for single-processor systems
yet are often used in multiprocessor systems?
A:"Spinlocks should not be used on single-processor systems. Consider a high
priority thread which attempts to claim a spinlock already held by a lower
priority thread: it will just loop forever and the lower priority thread will
never get another chance to run and release the spinlock. Even if the two
threads were running at the same priority, the one attempting to claim the
spinlock would spin until it was timesliced and a lot of cpu time would be
wasted. If an interrupt handler tried to claim a spinlock owned by a thread,
the interrupt handler would loop forever. Therefore spinlocks are only
appropriate for SMP systems where the current owner of a spinlock can
continue running on a different processor. "
老實說有點有看沒有很懂
有板友能用淺顯一點的話幫我解釋一下嗎 謝謝> <
還是說有更簡潔的說法 不用那麼複雜呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.57.123.227