What is the difference between a spinlock and a blocking lock? When would you prefer one over the other?

Last updated 5 July 2026

  • A spinlock busy-waits in a loop: no context-switch cost but wastes CPU, and it only makes sense on multiprocessors.

  • A blocking lock puts the waiter to sleep and wakes it later: frees the CPU but costs two context switches.

  • Use spinlocks for short, predictable critical sections on multicore (e.g. kernel data structures). Use blocking locks for long or unpredictable holds or I/O. Adaptive mutexes spin briefly, then block.

  • https://growthequityinterviewguide.com/firms/b-capital
  • https://www.interviewbit.com/sre-interview-questions/
  • https://www.reddit.com/r/cscareeradvice/new/
  • https://www.reddit.com/r/macbook/comments/1jg7fl6/24gb_ram_enough_for_software_engineering/
  • https://www.reddit.com/r/infosys/comments/1t71add/anyone_received_round_2_mails/
  • https://www.reddit.com/r/cscareeradvice/best/
  • https://www.reddit.com/r/LeetcodeChallenge/
  • https://www.reddit.com/r/infosys/comments/1t71i55/infosys_specialist_programmer_april_26_1st_round/
  • https://www.reddit.com/r/programming/comments/1hqo19u/static_search_trees_40x_faster_than_binary_search/
All Operating Systems interview questions