Bird
Raised Fist0

You are designing a synchronization mechanism for two processes on a system without atomic test-and-set instructions. Why might you choose Peterson's algorithm over hardware locks?

hard🌍 Real-world Scenario Q9 of Q15
Operating Systems - Critical Section Problem - Requirements & Peterson's Solution
You are designing a synchronization mechanism for two processes on a system without atomic test-and-set instructions. Why might you choose Peterson's algorithm over hardware locks?
ABecause Peterson's algorithm requires no special hardware support and guarantees mutual exclusion
BBecause hardware locks are always slower than software algorithms
CBecause Peterson's algorithm scales better to many processes
DBecause hardware locks cannot guarantee bounded waiting
Step-by-Step Solution
Solution:
  1. Step 1: Consider hardware support availability

    Peterson's algorithm works without atomic hardware instructions.
  2. Step 2: Analyze options

    Because Peterson's algorithm requires no special hardware support and guarantees mutual exclusion correctly states Peterson's algorithm requires no special hardware and guarantees mutual exclusion. Because hardware locks are always slower than software algorithms is false; hardware locks are often faster. Because Peterson's algorithm scales better to many processes is false; Peterson's algorithm does not scale well beyond two processes. Because hardware locks cannot guarantee bounded waiting is false; hardware locks can guarantee bounded waiting depending on implementation.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Peterson's algorithm is software-only and guarantees mutual exclusion [OK]
Quick Trick: Peterson's algorithm needs no atomic hardware instructions [OK]
Common Mistakes:
MISTAKES
  • Assuming hardware locks are always slower
  • Believing Peterson's scales to many processes
Trap Explanation:
PITFALL
  • Candidates often misunderstand hardware lock performance and scalability of Peterson's algorithm.
Interviewer Note:
CONTEXT
  • Evaluates candidate's ability to choose synchronization based on hardware constraints.
Master "Critical Section Problem - Requirements & Peterson's Solution" in Operating Systems

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Operating Systems Quizzes