Practice
Solution
Step 1: Understand Peterson's turn variable role
When both processes set their flags and turn, the turn variable decides who waits.Step 2: Mutual exclusion enforcement
The process whose turn it is not will wait until the other finishes, ensuring only one enters the critical section.Step 3: Deadlock and race condition avoidance
Peterson's algorithm prevents both deadlock and simultaneous entry.Final Answer:
Option C -> Option CQuick Check:
Mutual exclusion is guaranteed by the turn variable and flags.
- Believing both can enter critical section simultaneously
- Thinking the last to set turn always goes first
- Assuming deadlock can occur here
Solution
Step 1: Understand FCFS characteristics
FCFS schedules processes in the order they arrive without preemption, making it simple and fair in terms of arrival order.Step 2: Analyze each option
A is incorrect because FCFS does not optimize for similar burst times; it just queues by arrival.
B is incorrect because FCFS can cause long waiting times if a long process arrives first.
C is incorrect because FCFS is non-preemptive and does not handle unpredictable arrivals well.
D is correct because FCFS's main advantage is simplicity and fairness in order, not responsiveness or waiting time optimization.Final Answer:
Option D -> Option DQuick Check:
FCFS is chosen for simplicity and fairness, not for minimizing waiting time or handling preemption.
- Assuming FCFS minimizes average waiting time
- Confusing FCFS with preemptive scheduling
- Believing FCFS handles unpredictable arrivals efficiently
Solution
Step 1: Identify external fragmentation effect
External fragmentation means free memory is split into small noncontiguous blocks.Step 2: Understand system response
Compaction rearranges memory to create larger contiguous free blocks, enabling allocation.Step 3: Evaluate other options
Immediate rejection (B) ignores compaction; buddy system merges only buddies, not all blocks (C); internal fragmentation (D) is unrelated to external fragmentation.Final Answer:
Option D -> Option DQuick Check:
Compaction is the standard response to external fragmentation [OK]
- Assuming buddy system merges all free blocks automatically
- Believing internal fragmentation can solve external fragmentation
- Thinking system rejects requests without compaction
Solution
Step 1: Analyze memory overhead
Threads share memory, so they have lower memory overhead than processes, making Because threads have higher memory overhead than processes incorrect.Step 2: Consider synchronization issues
Shared memory requires synchronization mechanisms (locks, mutexes), which can cause contention and reduce performance.Step 3: Evaluate context switching speed
Thread context switching is generally faster than process switching, so Because thread context switching is slower than process context switching is false.Step 4: Understand CPU core utilization
Threads can run on multiple cores simultaneously, so Because threads cannot run on multiple CPU cores simultaneously is false.Final Answer:
Option C -> Option CQuick Check:
Synchronization overhead can limit thread performance gains [OK]
- Assuming threads always outperform processes
- Confusing context switch overhead between threads and processes
- Believing threads cannot utilize multiple cores
Solution
Step 1: Define livelock behavior
Livelock involves processes actively changing states but failing to make progress, unlike deadlock where processes are blocked.Step 2: Analyze each statement
Livelock occurs when processes continuously change state in response to each other without making progress correctly describes livelock. Livelock can be resolved by introducing random delays or backoff strategies is true; random backoff can resolve livelock. In livelock, processes are blocked and waiting indefinitely for resources is incorrect because livelock processes are not blocked but active. Livelock differs from deadlock because processes remain active rather than blocked correctly contrasts livelock and deadlock.Final Answer:
Option D -> Option DQuick Check:
Livelock means active but no progress, not blocked waiting.
- Confusing livelock with deadlock
- Assuming livelock processes are blocked
