Courses / HEC NSCT – National Skill Competency Test: Complete Preparation for Computing Graduates

9.3 Synchronization and Deadlocks

Area 9 – Operating Systems (5%) · 45 min read · 8 MCQs to check yourself

Critical section problem

When threads/processes share data, a race condition gives results that depend on timing. The critical section (code touching shared data) needs:

  1. Mutual exclusion – one at a time.
  2. Progress – a decision is made if no one is inside.
  3. Bounded waiting – no one waits forever.

Tools

Deadlock

A set of processes each waiting for a resource held by another. All four Coffman conditions must hold:

  1. Mutual exclusion 2. Hold and wait 3. No pre-emption 4. Circular wait. Handling: prevention (break one condition, e.g. order resources to stop circular wait), avoidance (Banker's algorithm grants a request only if the system stays in a safe state), detection and recovery (wait-for graph, kill/roll back a process), or ignore it (ostrich approach – common in desktop OSs). Starvation = waiting indefinitely (not necessarily a deadlock); livelock = processes keep changing state but make no progress.

Deadlock concept and necessary conditions (Gate Smashers)

This lesson ends with a quiz of 8 MCQs. Open the lesson on PrepOasis to take it and save your progress.

Previous: 9.2 CPU Scheduling · Next: 9.4 Memory, Virtual Memory and File Systems

All lessons in HEC NSCT – National Skill Competency Test: Complete Preparation for Computing Graduates