CSC264 · TU past paper
Operating Systems 2080 question paper
The complete TU 2080 exam paper for Operating Systems (CSC264), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- Q1.10 marksNumericalProcess SchedulingHideAnswer
(question text pending review) # Answer
When does the request switch from user mode to kernel mode?
A request switches from user mode to kernel mode through a system call (also calle
User Mode to Kernel Mode Switch + Process Scheduling
Given Data
Process Arrival Time (AT) Burst Time (BT) Priority P0 0 5 1 (Lowest) P1 1 3 4 (Highest) P2 2 8 2 P3 3 6 3 Priority convention (from question): higher number = higher priority (P1 = 4 = Highest).
Part 1: User Mode to Kernel Mode Switch
A CPU runs in two modes controlled by a mode bit:
- User Mode (bit = 1): application programs run with restricted privileges.
- Kernel Mode (bit = 0): the OS runs with full hardware access.
The switch from user mode to kernel mode occurs whenever a user process needs a privileged operation it cannot perform itself. This is triggered by:
Trigger Description System Call Process requests an OS service (file I/O, memory allocation) Hardware Interrupt External device signals CPU (keyboard, disk, timer) Trap / Exception Error condition (division by zero, page fault, invalid access) Mechanism: user process issues a system-call/trap instruction → CPU saves user state → mode bit set to 0 (kernel) → OS runs the system-call handler → on completion, mode bit set to 1 (user) → control returns to the process.
Example:
int fd = open("file.txt", O_RDONLY); // system callThe
open()call traps into the kernel. The CPU switches to kernel mode, the kernel checks permissions and locates the file, returns a file descriptor, then switches back to user mode. The process cannot touch the disk directly, so it must request the kernel to act on its behalf.
Part 2: Process Scheduling
Algorithm 1: FCFS (Non-preemptive, by arrival order)
Order: P0 → P1 → P2 → P3
Gantt Chart
| P0 | P1 | P2 | P3 | 0 5 8 16 22Process AT BT CT TAT = CT-AT WT = TAT-BT P0 0 5 5 5 0 P1 1 3 8 7 4 P2 2 8 16 14 6 P3 3 6 22 19 13 $$\text{Avg TAT} = \frac{5+7+14+19}{4} = \frac{45}{4} = 11.25 \text{ ms}$$ $$\text{Avg WT} = \frac{0+4+6+13}{4} = \frac{23}{4} = 5.75 \text{ ms}$$
Algorithm 2: Priority Scheduling (Non-preemptive, higher number = higher priority)
- t=0: only P0 arrived → run P0 (until t=5).
- t=5: P1(4), P2(2), P3(3) available → highest is P1 (until t=8).
- t=8: P2(2), P3(3) → highest is P3 (until t=14).
- t=14: only P2 → run (until t=22).
Gantt Chart
| P0 | P1 | P3 | P2 | 0 5 8 14 22Process AT BT CT TAT = CT-AT WT = TAT-BT P0 0 5 5 5 0 P1 1 3 8 7 4 P3 3 6 14 11 5 P2 2 8 22 20 12 $$\text{Avg TAT} = \frac{5+7+11+20}{4} = \frac{43}{4} = 10.75 \text{ ms}$$ $$\text{Avg WT} = \frac{0+4+5+12}{4} = \frac{21}{4} = 5.25 \text{ ms}$$
Algorithm 3: Round Robin (Quantum = 2, preemptive)
BTs: P0=5, P1=3, P2=8, P3=6. Ready-queue ordering by arrival; a preempted process rejoins the tail after newly arrived processes.
Trace the ready queue (arrivals: P0@0, P1@1, P2@2, P3@3):
Time Run Remaining after Queue state after 0-2 P0 3 P1 arrived@1, P2@2 present; queue: P1,P2,P0 (P3@3 next) 2-4 P1 1 during run P3@3 arrives → queue: P2,P0,P3,P1 4-6 P2 6 queue: P0,P3,P1,P2 6-8 P0 1 queue: P3,P1,P2,P0 8-10 P3 4 queue: P1,P2,P0,P3 10-11 P1 0 → CT=11 queue: P2,P0,P3 11-13 P2 4 queue: P0,P3,P2 13-14 P0 0 → CT=14 queue: P3,P2 14-16 P3 2 queue: P2,P3 16-18 P2 2 queue: P3,P2 18-20 P3 0 → CT=20 queue: P2 20-22 P2 0 → CT=22 empty Gantt Chart
|P0|P1|P2|P0|P3|P1|P2|P0|P3|P2|P3|P2| 0 2 4 6 8 10 11 13 14 16 18 20 22Process AT BT CT TAT = CT-AT WT = TAT-BT P0 0 5 14 14 9 P1 1 3 11 10 7 P2 2 8 22 20 12 P3 3 6 20 17 11 $$\text{Avg TAT} = \frac{14+10+20+17}{4} = \frac{61}{4} = 15.25 \text{ ms}$$ $$\text{Avg WT} = \frac{9+7+12+11}{4} = \frac{39}{4} = 9.75 \text{ ms}$$
Summary
Algorithm Avg Waiting Time Avg Turnaround Time FCFS 5.75 ms 11.25 ms Priority (non-preemptive) 5.25 ms 10.75 ms Round Robin (Q=2) 9.75 ms 15.25 ms - Q2.10 marksNumericalCritical SectionHideAnswer
How do you recognize critical section? Why do we need to synchronise it? Consider the request for the page references 7,0,1,2,0,3,0,4,2,3,0,3,2. Find the number of page fault for FIFO and LRU with 4 page frames.[10]
- Q3.10 marksConditions for DeadlockHideAnswer
Can deadlock occur in case of preemptive resources? List the conditions for deadlock. Define allocation graph with example.[10]
- Q4.5 marksMemory Allocation StrategiesHideAnswer
Explain different memory allocation strategies. [5]
- Q5.5 marksNumericalDisk SchedulingHideAnswer
Suppose a disk has 201 cylinders, numbered from 0 to 200. At same time the disk arm is at cylinder 10, and there is a queue of disk access requests for cylinders 30, 85, 90, 100, 105, 110, 135, and 145. Find the total seek time for the disk scheduling algorithm FCFS and SSTF. Assume the head is moving inward. [5]
- Q6.5 marksInterruptsHideAnswer
What are the advantages of using interrupt? Describe. [5]
- Q7.5 marksImplementing FilesHideAnswer
Differentiate between contiguous and linked list file allocation technique. [5]
- Q8.5 marksSegmentationHideAnswer
Differentiate between paging and segmentation. [5]
- Q9.5 marksBelady's AnomalyHideAnswer
What does Belady's anomaly mean? What are the benefits of multiprogramming over uniprogramming? [5]
- Q10.5 marksImplementing Mutual ExclusionHideAnswer
How can we achieve mutual exclusion? Describe. [5]
- Q11.5 marksThread vs ProcessHideAnswer
What makes thread different with process? Draw the transition diagram between states of a process. [5]
- Q12.5 marksVirtual memoryHideAnswer
When does a page fault occur? Give a structure of a page table. [5]