IITIAN1997 STUDIO

Operating systems

JLEE CSE · 10 practice questions with answers

Practise and take a mock test →

Processes, scheduling, deadlock, memory, files

Topics: OS functions and types; processes and threads; CPU scheduling; synchronisation, semaphores; deadlock; memory management, paging, segmentation, virtual memory; file systems; disk scheduling.

Processes and CPU scheduling

A process moves through new, ready, running, waiting and terminated states. Scheduling: FCFS, SJF (minimum average waiting time), priority, and round robin with a time quantum (fair, good for time-sharing). Waiting time = completion − arrival − burst; turnaround = completion − arrival.

  • Waiting = turnaround − burst
  • SJF minimises average waiting
  • RR: time quantum, preemptive

Example: P1 = 5, P2 = 3, P3 = 1 ms arrive at 0. Round robin with quantum 2: find the average waiting time.

  1. Order: P1 0–2, P2 2–4, P3 4–5, P1 5–7, P2 7–8, P1 8–9; completions 9, 8, 5.
  2. Waits: 9 − 5 = 4, 8 − 3 = 5, 5 − 1 = 4; average ≈ 4.33 ms.

Answer: ≈ 4.33 ms

Example: Which scheduling algorithm gives the minimum average waiting time?

  1. Running short jobs first reduces everyone’s waiting.
  2. Shortest job first.

Answer: SJF

Synchronisation and deadlock

Shared data needs mutual exclusion: semaphores with wait (P) and signal (V), mutexes, monitors. Deadlock needs all four Coffman conditions: mutual exclusion, hold and wait, no preemption, circular wait; breaking any one prevents it. The banker’s algorithm avoids deadlock by granting requests only if a safe sequence remains.

  • Four Coffman conditions
  • Semaphore: wait/signal
  • Banker’s: keep a safe sequence

Example: 12 units exist. P1, P2, P3 hold 5, 2, 2 and may need up to 10, 4, 9. Is the state safe?

  1. Available = 3; remaining needs 5, 2, 7. P2 can finish (2 ≤ 3), freeing 2 → 5 available.
  2. Then P1 (5 ≤ 5) → 10, then P3 (7 ≤ 10): safe sequence P2, P1, P3.

Answer: Safe: P2, P1, P3

Example: Name the deadlock condition broken by requesting all resources at once.

  1. A process no longer holds some resources while waiting for others.
  2. Hold and wait.

Answer: Hold and wait

Memory, virtual memory and disks

Paging splits memory into fixed frames: logical address = page number × page size + offset. Virtual memory loads pages on demand; when memory is full a page-replacement algorithm chooses a victim: FIFO (oldest), LRU (least recently used), optimal (used farthest in future). Disk scheduling: FCFS, SSTF, SCAN, C-SCAN; total head movement measures cost.

  • page = ⌊address / page size⌋
  • LRU usually beats FIFO
  • Head movement = Σ|jumps|

Example: Page size 4 KB: find the page and offset of logical address 13 000.

  1. 13 000 ÷ 4096 = 3 remainder 712.
  2. Page 3, offset 712.

Answer: Page 3, offset 712

Example: With 3 frames and references 7 0 1 2 0 3 0 4 2 3, count faults for FIFO and LRU.

  1. FIFO evicts the oldest: 9 faults.
  2. LRU evicts the least recently used: 8 faults.

Answer: FIFO 9, LRU 8

Example: Head at 50; FCFS requests 82, 170, 43, 140. Find the total head movement.

  1. 32 + 88 + 127 + 97.
  2. = 344 cylinders.

Answer: 344

A process is a program in execution and moves through new, ready, running, waiting and terminated states; threads share its address space. FCFS, SJF, priority and round robin schedule the CPU; SJF minimises average waiting time, and round robin gives time slices. Semaphores synchronise critical sections. Deadlock needs four conditions at once: mutual exclusion, hold and wait, no preemption, circular wait; the banker’s algorithm avoids it. Paging divides memory into fixed frames and causes internal fragmentation; segmentation uses variable segments and causes external fragmentation. Virtual memory pages on demand, with replacement by FIFO, LRU or Optimal. Thrashing is excessive paging. Disk scheduling includes FCFS, SSTF, SCAN and C-SCAN.

  • Context switch saves and restores process state in a PCB.
  • Belady’s anomaly affects FIFO.
  • Turnaround time = completion − arrival; waiting = turnaround − burst.
  • Starvation is cured by ageing.
  • Unix: fork creates a process; exec replaces it.

Key formulas

  • TAT = CT − AT
  • WT = TAT − BT
  • page offset bits = log₂(page size)

Practice questions

The scheduler minimising average waiting time is

  1. FCFS
  2. SJF
  3. round robin
  4. random
Show the answer

Answer: B. SJF Optimal if bursts known.

Round robin uses

  1. a time quantum
  2. longest job first
  3. no pre-emption
  4. priority only
Show the answer

Answer: A. a time quantum Time slices.

Which is NOT a deadlock condition?

  1. mutual exclusion
  2. hold and wait
  3. pre-emption
  4. circular wait
Show the answer

Answer: C. pre-emption No pre-emption is required.

The banker’s algorithm

  1. avoids deadlock
  2. schedules disks
  3. translates addresses
  4. sorts files
Show the answer

Answer: A. avoids deadlock Safe states.

Paging causes

  1. internal fragmentation
  2. external fragmentation only
  3. no fragmentation ever
  4. thrashing always
Show the answer

Answer: A. internal fragmentation Partly filled last page.

Thrashing means

  1. excessive paging
  2. disk format
  3. fast CPU
  4. deadlock always
Show the answer

Answer: A. excessive paging CPU idle waiting.

Belady’s anomaly is seen in

  1. FIFO
  2. LRU
  3. Optimal
  4. all stack algorithms
Show the answer

Answer: A. FIFO More frames, more faults.

Threads of one process share

  1. address space
  2. registers and stack
  3. PC
  4. nothing
Show the answer

Answer: A. address space Own stack and registers.

Ageing solves

  1. starvation
  2. paging
  3. booting
  4. parity
Show the answer

Answer: A. starvation Raises priority with time.

SCAN disk scheduling is also called

  1. elevator
  2. lift-off
  3. round robin
  4. FCFS
Show the answer

Answer: A. elevator Elevator algorithm.

The practice questions were written for this studio; they are not copied from ASTU papers. ASTU publishes no topic syllabus for these exams, so the topics are an informed guide based on diploma courses, not an official list.

Practise and take a mock test →