Independent Preparation Bank for Pakistani Computing Graduates • 100% Free • No Signup
NSCTPrep.
All Articles
Home/Articles/Subject Deep-Dive
Subject Deep-Dive

Operating Systems & Concurrency: Process Scheduling, Deadlocks & Virtual Memory

A targeted 5% subject that can make or break a competitive percentile. Master Banker's algorithm, Coffman conditions, paging page-replacement algorithms, and CPU scheduling.

NSCT Editorial & Syllabus Hub
Curated Technical Curriculum & Testing Benchmarks
7 min readNov 16, 2026Mock Exam

Operating Systems & Concurrency: Process Scheduling, Deadlocks & Virtual Memory

Operating Systems represents 5% of the overall NSCT score. Because the questions are highly standardized, scoring 5/5 in this domain requires mastering four key areas: process scheduling, synchronization primitives, deadlock conditions, and virtual memory paging.


1. Process States & CPU Scheduling

A process transitions through: New $ ightarrow$ Ready $ ightarrow$ Running $ ightarrow$ Waiting (Blocked) $ ightarrow$ Terminated.

CPU Scheduling Algorithms

  • First-Come, First-Served (FCFS): Non-preemptive. Suffers from the Convoy Effect where short processes wait behind long CPU-burst processes.
  • Shortest Job First (SJF): Optimal minimum average waiting time. Impossible to implement perfectly in general OS because next CPU burst length cannot be known in advance.
  • Shortest Remaining Time First (SRTF): Preemptive version of SJF.
  • Round Robin (RR): Preemptive scheduling designed for time-sharing systems using a Time Quantum ($q$).
    • If $q$ is extremely large, RR degenerates to FCFS.
    • If $q$ is extremely small, excessive context switching overhead degrades throughput.
  • Priority Scheduling: Can cause starvation (low priority processes never run). Solution: Aging (gradually increasing priority of processes waiting for long periods).

2. Process Synchronization & Critical Section Problem

Any valid solution to the Critical Section problem must satisfy three requirements:

  1. Mutual Exclusion: If process $P_i$ is executing in its critical section, no other processes can be in theirs.
  2. Progress: If no process is in its critical section and some processes wish to enter, only those not in their remainder section can participate in deciding who enters next.
  3. Bounded Waiting: There must be a bound on the number of times other processes are allowed to enter their critical sections after a process has requested entry.

Mutex vs Counting Semaphore

  • Mutex: Binary lock (0 or 1) owned by a single thread. Only the thread that acquired the mutex can release it.
  • Counting Semaphore: Integer counter initialized to resource count $N$.
    • wait() / P(): Decrements counter. If counter $< 0$, process blocks.
    • signal() / V(): Increments counter. If counter $\le 0$, wakes a waiting process.

3. Deadlocks & The 4 Coffman Conditions

A deadlock can occur if and only if all four conditions hold simultaneously:

  1. Mutual Exclusion: At least one resource must be held in a non-shareable mode.
  2. Hold and Wait: A process must be holding at least one resource and waiting to acquire additional resources held by other processes.
  3. No Preemption: Resources cannot be forcibly preempted; they are released only voluntarily by the holding process.
  4. Circular Wait: A closed chain of processes exists where each process holds resources needed by the next process in the chain.

Banker’s Algorithm: Used for Deadlock Avoidance by ensuring the system remains in a Safe State before granting resource allocation requests.


4. Virtual Memory & Page Replacement Algorithms

Virtual memory maps logical addresses to physical memory frames via a Page Table.

  • Page Fault: Occurs when a referenced virtual page is not currently mapped into physical RAM (valid bit = 0), triggering an OS interrupt to fetch the page from disk.
  • Thrashing: Occurs when the system spends more time servicing page faults and swapping pages than executing actual application code.

Common Page Replacement Algorithms

  • FIFO (First-In, First-Out): Replaces oldest page. Suffers from Belady’s Anomaly (allocating more physical page frames can paradoxically increase the number of page faults!).
  • LRU (Least Recently Used): Replaces the page that has not been used for the longest period of time. Immune to Belady's Anomaly (Stack algorithm).
  • Optimal (OPT / MIN): Replaces the page that will not be used for the longest period in the future. Theoretical upper bound benchmark.
Indexed Competency Concepts:
#Operating Systems#Deadlocks#Virtual Memory#Semaphores#CPU Scheduling
Official Standards Verification

Content structured in accordance with Higher Education Commission (HEC) Computing National Curriculum, PSEB TechLift competency standards, and the 120-minute Virtual University assessment model.