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.
- 110 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 - 210 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]
--- A critical section is the segment of code in a process where it accesses and manipulates shared resources (shared variables, memory, files, buffers, etc.) that must not be accessed by more than one process simultaneously. How to reco...
- 310 marksConditions for DeadlockHideAnswer
Can deadlock occur in case of preemptive resources? List the conditions for deadlock. Define allocation graph with example.[10]
--- No, deadlock cannot occur in the case of preemptive resources. One of the four necessary conditions for deadlock is No Preemption, which states: "A process acquiring a resource cannot be preempted in between to release the acquired r...
- 45 marksMemory Allocation StrategiesHideAnswer
Explain different memory allocation strategies. [5]
Memory allocation strategies are methods used by the process manager to allocate free memory partitions (holes) to processes. The main strategies are described below: --- The process manager scans the list of segments from the beginning ...
- 55 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]
- Total cylinders: 201 (numbered 0 to 200) - Initial head position: cylinder 10 - Request queue (order of arrival): 30, 85, 90, 100, 105, 110, 135, 145 - Head moving inward (toward higher cylinder numbers) --- Requests served in arrival ...
- 65 marksInterruptsHideAnswer
What are the advantages of using interrupt? Describe. [5]
"The hardware mechanism that enables a device to notify the CPU is called an interrupt. Interrupt forces CPU to stop what it is doing and start doing something else. Interrupts are signals sent to the CPU by external devices, normally I/...
- 75 marksImplementing FilesHideAnswer
Differentiate between contiguous and linked list file allocation technique. [5]
As stated in the notes, "the simplest allocation scheme is to store each file as a contiguous run of disk blocks." Each file occupies a set of consecutive blocks on the disk. The directory entry stores only the starting block address and...
- 85 marksSegmentationHideAnswer
Differentiate between paging and segmentation. [5]
Paging and segmentation are both memory management techniques used by operating systems, but they differ in several important ways. --- Basis Paging Segmentation --------- Block Size Page is always of fixed block size. Segment is of vari...
- 95 marksBelady's AnomalyHideAnswer
What does Belady's anomaly mean? What are the benefits of multiprogramming over uniprogramming? [5]
--- Belady's anomaly is the phenomenon in which increasing the number of page frames results in an increase in the number of page faults for certain memory access patterns. This is a counter-intuitive behavior because logically, more fra...
- 105 marksImplementing Mutual ExclusionHideAnswer
How can we achieve mutual exclusion? Describe. [5]
Mutual exclusion ensures that when one process is executing in its critical region (accessing shared memory/resources), no other process is allowed to enter its critical region at the same time. --- - On a single-processor system, each p...
- 115 marksThread vs ProcessHideAnswer
What makes thread different with process? Draw the transition diagram between states of a process. [5]
Based on the curriculum notes, the key differences are: Process Thread ------ Process is heavy weight or resource intensive. Thread is light weight, taking lesser resources than a process. Process switching needs interaction with the ope...
- 125 marksVirtual memoryHideAnswer
When does a page fault occur? Give a structure of a page table. [5]
A page fault occurs when a program attempts to access data or code that is in its address space, but is not currently located in the system RAM (i.e., the required page is not present in physical memory). When a page fault occurs, the fo...