Operating Systems - Semaphore vs Mutex - When to Use WhichWhat issue arises if a binary semaphore used as a mutex is initialized with a value greater than 1?AIt behaves exactly like a mutex with no issuesBIt causes the semaphore to deadlock immediatelyCIt allows multiple threads to enter the critical section simultaneously, breaking mutual exclusionDIt prevents any thread from entering the critical sectionCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand binary semaphore initializationBinary semaphore initialized >1 allows multiple acquires without blocking.Step 2: Effect on mutual exclusionMultiple threads can enter critical section simultaneously, violating mutual exclusion.Final Answer:Option C -> Option CQuick Check:Binary semaphore >1 breaks mutual exclusion [OK]Quick Trick: Binary semaphore must be initialized to 1 for mutex behavior [OK]Common Mistakes:MISTAKESAssuming semaphore >1 still enforces exclusionThinking it causes deadlockBelieving it blocks all threadsTrap Explanation:PITFALLHigher initial count allows multiple concurrent entries, unlike mutexInterviewer Note:CONTEXTTests understanding of semaphore initialization and mutual exclusion
Master "Semaphore vs Mutex - When to Use Which" in Operating Systems2 interactive learning modes - each teaches the same concept differentlySolutionTrace
More Operating Systems Quizzes Critical Section Problem - Requirements & Peterson's Solution - Critical Section Problem - Requirements & Peterson's Solution - Quiz 8hard Disk Scheduling - SSTF, SCAN, C-SCAN - Disk Scheduling - SSTF, SCAN, C-SCAN - Quiz 2easy File Allocation Methods - Contiguous, Linked, Indexed - File Allocation Methods - Contiguous, Linked, Indexed - Quiz 8hard File Allocation Methods - Contiguous, Linked, Indexed - File Allocation Methods - Contiguous, Linked, Indexed - Quiz 12easy Internal vs External Fragmentation - Compaction & Buddy System - Internal vs External Fragmentation - Compaction & Buddy System - Quiz 3easy Internal vs External Fragmentation - Compaction & Buddy System - Internal vs External Fragmentation - Compaction & Buddy System - Quiz 4medium Producer-Consumer Problem Using Semaphores - Producer-Consumer Problem Using Semaphores - Quiz 8hard Shortest Job First (SJF) - Preemptive vs Non-Preemptive - Shortest Job First (SJF) - Preemptive vs Non-Preemptive - Quiz 4medium Starvation vs Deadlock vs Livelock - Differences & Examples - Starvation vs Deadlock vs Livelock - Differences & Examples - Quiz 11easy System Call - Mechanism & Modes (User vs Kernel) - System Call - Mechanism & Modes (User vs Kernel) - Quiz 3easy