University

Operating Systems Practice Exam — Free

Generate a realistic AI practice exam with worked solutions

Generate Your Free Practice Exam

Operating Systems covers processes and threads, scheduling, synchronization, deadlock, memory management, and file systems. Exams mix short conceptual questions with worked scenarios — scheduling timelines, page-replacement traces, semaphore proofs. Practicing those traces against step-by-step solutions is the difference between recognizing the pattern and re-deriving it under time pressure.

Crameleon generates your practice exam from your own course materials — lecture notes, syllabi, past exams, or any combination. Upload what you have and get a fully formatted exam with the same structure as your professor's actual tests: multiple choice, short answer, and worked problems, all with step-by-step solutions (first 2 free; all with Premium).

Unlike generic question banks, every Crameleon exam reflects the specific framing, terminology, and difficulty level of your course. You'll practise answering questions that look and feel like the real thing — which is exactly what the research on retrieval practice says you should be doing. Students who test themselves with practice exams consistently outperform students who re-read notes, regardless of study time. The generation takes under 2 minutes and your first exam is completely free.

Topics typically tested

  • Processes, threads & context switching
  • CPU scheduling algorithms
  • Synchronization (mutexes, semaphores, monitors)
  • Deadlock conditions & handling
  • Virtual memory & page replacement
  • File systems & I/O

Sample Operating Systems exam questions

Three original questions in the style of a real Operating Systems exam, each with a worked solution. Your own practice exam can be built from your course's notes and syllabus.

Question 1Multiple choiceVirtual memory & page replacement

A process is allocated 3 page frames, all initially empty, and generates the page-reference string 1, 3, 2, 1, 4, 3, 5, 1, 2, 3. How many page faults occur under the LRU (least recently used) replacement policy? Count the initial loads as faults.

  1. A.

    5

  2. B.

    6

  3. C.

    8

  4. D.

    9

Worked solution
Answer:D

LRU evicts the page whose most recent use is furthest in the past. Track the frames with the least recently used page on the left; a hit moves that page to the most-recent end.

ReferenceFrames (LRU → MRU)Result
11fault
31, 3fault
21, 3, 2fault
13, 2, 1hit
42, 1, 4fault (evict 3)
31, 4, 3fault (evict 2)
54, 3, 5fault (evict 1)
13, 5, 1fault (evict 4)
25, 1, 2fault (evict 3)
31, 2, 3fault (evict 5)

That is 9 faults: the three compulsory loads plus six replacements. Only the second reference to page 1 is a hit; every later reference arrives just after its page was evicted, which is the worst pattern for LRU.

Option C (8) is the tempting answer because it is the FIFO count for the same string: FIFO keeps page 3 (loaded second) long enough to score a hit on the sixth reference, so FIFO beats LRU here, a reminder that LRU is not always better. Option B (6) is the optimal (Belady) count, the lower bound that no online policy can beat on this string. Option A (5) is merely the number of distinct pages, which would be the fault count only if the process had enough frames to hold all of them.

9 page faults (option D).

Question 2Short answerCPU scheduling algorithms

Four processes arrive at a single-CPU system: P1 arrives at time 0 with a CPU burst of 7 ms, P2 at 1 ms with a burst of 4 ms, P3 at 2 ms with a burst of 1 ms, and P4 at 3 ms with a burst of 2 ms. The scheduler is preemptive shortest-job-first (shortest remaining time first), and context switches take no time. Find the completion time of each process and the average waiting time.

Worked solution
Answer:

P1 completes at 14 ms, P2 at 8 ms, P3 at 3 ms, P4 at 5 ms; average waiting time = 2.5 ms

Shortest remaining time first always runs the ready process with the least remaining CPU time, re-evaluating whenever a new process arrives.

  • t=0t = 0: only P1 is present; it runs (7 remaining).
  • t=1t = 1: P2 arrives with 4, less than P1's remaining 6, so P2 preempts P1.
  • t=2t = 2: P3 arrives with 1, less than P2's remaining 3, so P3 runs and finishes at t=3t = 3.
  • t=3t = 3: P4 arrives with 2. Ready: P1 (6), P2 (3), P4 (2). P4 runs and finishes at t=5t = 5.
  • t=5t = 5: P2 (3 remaining) runs and finishes at t=8t = 8.
  • t=8t = 8: P1 (6 remaining) runs and finishes at t=14t = 14.

The CPU is never idle, and the last completion at 14 ms equals the sum of all bursts (7+4+1+2=147+4+1+2 = 14), which checks the timeline.

Waiting time is turnaround minus burst, where turnaround is completion minus arrival:

  • P1: 14−0−7=714-0-7 = 7 ms
  • P2: 8−1−4=38-1-4 = 3 ms
  • P3: 3−2−1=03-2-1 = 0 ms
  • P4: 5−3−2=05-3-2 = 0 ms

Average waiting time =(7+3+0+0)/4=2.5= (7+3+0+0)/4 = 2.5 ms. For comparison, first-come first-served would run P1, P2, P3, P4 back to back with waiting times 0, 6, 9 and 9 ms, an average of 6 ms, which illustrates why SRTF minimizes average waiting time when burst lengths are known.

Completion times: P1 = 14 ms, P2 = 8 ms, P3 = 3 ms, P4 = 5 ms; average waiting time = 2.5 ms.

Question 3Worked problemDeadlock conditions & handling

A system has three resource types A, B and C with 6, 5 and 6 instances respectively, shared by four processes. The current state is:

ProcessAllocation (A B C)Maximum (A B C)
P01 0 13 2 2
P12 1 04 1 1
P21 2 12 3 3
P30 1 21 2 4

(a) Compute the Available vector and the Need matrix. (b) Using the banker's algorithm, determine whether the state is safe; if so, give a safe sequence. (c) P2 now requests (1, 0, 1). Should the request be granted immediately? (d) Suppose instead that, from the state in (a), P0 requests (1, 0, 1). Should that request be granted? Justify both answers with the safety algorithm.

Worked solution
Answer:

(a) Available = (2, 1, 2); Need: P0 (2, 2, 1), P1 (2, 0, 1), P2 (1, 1, 2), P3 (1, 1, 2). (b) Safe; one safe sequence is P1, P2, P3, P0. (c) Yes: the resulting state is safe (for example P2, P1, P0, P3). (d) No: granting it leaves Available = (1, 1, 1) and no process's Need can then be met, so the state would be unsafe

(a) Available = total instances minus the column sums of Allocation: (6, 5, 6) − (4, 4, 4) = (2, 1, 2). Need = Maximum − Allocation:

ProcessNeed (A B C)
P02 2 1
P12 0 1
P21 1 2
P31 1 2

(b) Safety algorithm: start with Work = (2, 1, 2), repeatedly pick an unfinished process whose Need fits within Work, let it finish, and add its Allocation back. P0 needs 2 of B but only 1 is free, so skip it. P1 fits: Work = (2, 1, 2) + (2, 1, 0) = (4, 2, 2). P2 fits: Work = (5, 4, 3). P3 fits: Work = (5, 5, 5). P0 now fits: Work = (6, 5, 6). All four finish, so the state is safe; one safe sequence is P1, P2, P3, P0 (P1, P0, P2, P3 also works).

(c) P2's request (1, 0, 1) is within its Need (1, 1, 2) and within Available (2, 1, 2), so pretend to grant it: Available = (1, 1, 1), P2's Allocation = (2, 2, 2), Need = (0, 1, 1). Safety: P2 fits, Work = (3, 3, 3); P1 fits, Work = (5, 4, 3); P0 fits, Work = (6, 4, 4); P3 fits, Work = (6, 5, 6). The new state is safe, so the request is granted immediately.

(d) P0's request (1, 0, 1) is also within its Need (2, 2, 1) and within Available. Pretend to grant it: Available = (1, 1, 1), P0's Allocation = (2, 0, 2), Need = (1, 2, 0). Safety: P0 needs 2 of B, P1 needs 2 of A, and P2 and P3 each need 2 of C, but only one instance of each type is free. No process can finish, so the state would be unsafe: the request is denied and P0 is blocked until resources are released. The system is not deadlocked now; the banker refuses because it could no longer guarantee every maximum claim.

(a) Available = (2, 1, 2); Need rows (2, 2, 1), (2, 0, 1), (1, 1, 2), (1, 1, 2). (b) Safe, e.g. P1, P2, P3, P0. (c) Grant: the resulting state is safe. (d) Deny: the resulting state is unsafe.

Used by 3,000+ students across Canadian universities·Step-by-step solutions (first 2 free)·Works for any course

Ready to practice?

Generate Your Free Operating Systems Practice Exam

Your first exam is free — just sign in, no credit card.