CSC264 · TU past paper
Operating Systems 2079 question paper
The complete TU 2079 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 marksNumericalHandling DeadlocksHideAnswer
Banker's Algorithm Analysis
All files reside in one common directory shared by all users. Advantages: Simple to implement, easy to search, fast access. Disadvantages: All file names must be unique (naming collision), unsuitable for multiple users, becomes unmanagea...
- 210 marksRace ConditionHideAnswer
When does race condition occur in inter process communication? What does busy waiting mean and how it can be handled using sleep and wakeup strategy?[10]
A race condition is a situation that may occur inside a critical section. This happens when the result of multiple thread/process execution in a critical section differs according to the order in which the threads execute. Race condition...
- 310 marksNumericalDisk SchedulingHideAnswer
Define shell and system call. Suppose a disk has 201 cylinders, numbered from 0 to 200. At same time the disk arm is at cylinder 95, and there is a queue of disk access requests for cylinders 82,170,43,140,24,16 and 190. Calculate the seek time for the disk scheduling algorithm FCFS,SSTF,SCAN and C-SCAN.[10]
Shell, System Call, and Disk Scheduling
Part 1: Definitions
Shell
A shell is a command interpreter that provides the interface between the user and the operating system kernel. It accepts user commands, interprets them, and hands them to the OS for execution. It also lets users run programs, manage files, and control processes. Examples: Bash, sh, csh, zsh.
System Call
A system call is the programmatic interface through which a user process requests a service from the OS kernel. It transfers control from user mode to kernel mode for privileged operations. Examples:
fork(),exec(),read(),write(),open().
Part 2: Disk Scheduling
Given data:
- Cylinders: 201 (numbered 0 to 200)
- Head start: 95
- Queue (arrival order): 82, 170, 43, 140, 24, 16, 190
1. FCFS
Order: $95 \to 82 \to 170 \to 43 \to 140 \to 24 \to 16 \to 190$
$$|95-82|+|82-170|+|170-43|+|43-140|+|140-24|+|24-16|+|16-190|$$ $$= 13+88+127+97+116+8+174 = \boxed{623}$$
2. SSTF
Step Pos Closest Dist 1 95 82 13 2 82 43 39 3 43 24 19 4 24 16 8 5 16 140 124 6 140 170 30 7 170 190 20 Order: $95 \to 82 \to 43 \to 24 \to 16 \to 140 \to 170 \to 190$
$$13+39+19+8+124+30+20 = \boxed{253}$$
3. SCAN (moving up toward 200)
Sorted: $16, 24, 43, 82, [95], 140, 170, 190$
Order: $95 \to 140 \to 170 \to 190 \to 200 \to 82 \to 43 \to 24 \to 16$
$$45+30+20+10+118+39+19+8 = \boxed{289}$$
Total = $(200-95) + (200-16) = 105 + 184 = 289$ ✓
4. C-SCAN (moving up toward 200, then wrap to 0)
Order: $95 \to 140 \to 170 \to 190 \to 200 \to 0 \to 16 \to 24 \to 43 \to 82$
From To Dist 95 140 45 140 170 30 170 190 20 190 200 10 200 0 200 0 16 16 16 24 8 24 43 19 43 82 39 $$45+30+20+10+200+16+8+19+39 = \boxed{387}$$
Summary
Algorithm Total Seek (cylinders) FCFS 623 SSTF 253 SCAN 289 C-SCAN 387 - 45 marksIntroductionHideAnswer
Distinguish between starvation and deadlock. How does the system schedule process using multiple queues? [5]
--- Basis Deadlock Starvation --------- Definition A situation where a set of processes are blocked, each waiting for a resource held by another process in the same set, so none can proceed. A situation where a process waits indefinitely...
- 55 marksImplementing Mutual ExclusionHideAnswer
List any two demerits of disabling interrupt to achieve mutual exclusion. Describe about fixed and variable partitioning. [5]
Answer
Two Demerits of Disabling Interrupts for Mutual Exclusion
According to the notes, the following are two demerits of disabling interrupts to achieve mutual exclusion:
-
Unsafe to give power to user processes: It is unwise to give user processes the power to turn off interrupts. If a user process disables interrupts and never re-enables them, the entire system could come to a halt. This makes the approach unsuitable for general user-level processes.
-
Not appropriate for user processes: Disabling interrupts is only a useful technique within the operating system itself. It is not appropriate for user processes because a malfunctioning or malicious process could permanently disable interrupts, causing the system to stop functioning correctly.
Fixed and Variable Partitioning
In a multiprogramming environment, several programs reside in primary memory at the same time and the CPU switches control between them. One way to support multiprogramming is to divide main memory into several partitions, each allocated to a single process. Depending on how and when partitions are created, there are two types:
(i) Fixed Partitioning (Static Partitioning)
- Memory is divided into several fixed-size partitions before execution begins.
- Each partition can accommodate only one program at a time.
- The number of programs residing in memory is bounded by the number of partitions.
- When a program terminates, its partition is freed for another program waiting in the queue.
- When a job arrives, it is placed in the input queue for the smallest partition large enough to hold it.
Demerit: Since partitions are fixed in size, any unused space within a partition cannot be used by other jobs and is simply wasted while that job runs. This is known as internal fragmentation.
(ii) Variable Partitioning (Dynamic Partitioning)
- Partitions are not fixed in advance; they are created dynamically at the time a process is loaded into memory.
- Each process is allocated exactly as much memory as it requires, so there is no internal fragmentation.
- As processes finish and leave memory, holes (free blocks) are created at various places in memory.
- Over time, memory becomes fragmented into many small holes scattered throughout, which is known as external fragmentation.
- Techniques such as compaction may be used to combine these holes into one large free block.
Demerit: External fragmentation occurs over time, making it difficult to allocate contiguous memory to new processes without compaction.
Comparison Table
Feature Fixed Partitioning Variable Partitioning Partition size Fixed at system startup Determined at load time Internal fragmentation Yes No External fragmentation No Yes Flexibility Low High Implementation Simple More complex -
- 65 marksNumericalProcess SchedulingHideAnswer
For the following dataset, compute average waiting time for SRTN and SJF.
Process Arrival Time Burst Time P0 0 7 P1 2 4 P2 4 1 P3 5 4 [5]
SRTN and SJF Scheduling - Average Waiting Time
STEP 1 - Given Data
Process Arrival Time Burst Time P0 0 7 P1 2 4 P2 4 1 P3 5 4 All required data present.
STEP 2 - SOLVE
Part 1: SRTN (Shortest Remaining Time Next) - Preemptive
At each new arrival, compare remaining times and run the smallest.
Execution Trace
- t=0: Only P0. Run P0.
- t=2: P1 arrives (4). P0 remaining = 5. Since 4 < 5, run P1. (P0 rem = 5)
- t=4: P2 arrives (1). P1 remaining = 2. Since 1 < 2, run P2. (P0=5, P1=2)
- t=5: P2 finishes. P3 arrives (4). Ready: P1=2, P3=4, P0=5. Run P1.
- t=7: P1 finishes. Ready: P3=4, P0=5. Run P3.
- t=11: P3 finishes. Run P0 (5 remaining).
- t=16: P0 finishes.
Note: at $t=4$ the remaining time for P1 is $4 - 2 = \mathbf{2}$ units, since P1 ran from $t=2$ to $t=4$.
Gantt Chart
| P0 | P1 | P2 | P1 | P3 | P0 | 0 2 4 5 7 11 16Waiting Time (WT = Completion - Arrival - Burst)
Process Completion Arrival Burst Waiting Time P0 16 0 7 16 - 0 - 7 = 9 P1 7 2 4 7 - 2 - 4 = 1 P2 5 4 1 5 - 4 - 1 = 0 P3 11 5 4 11 - 5 - 4 = 2 $$\text{Average WT (SRTN)} = \frac{9 + 1 + 0 + 2}{4} = \frac{12}{4} = \boxed{3.0 \text{ ms}}$$
Part 2: SJF (Shortest Job First) - Non-Preemptive
- t=0: Only P0 arrived. Run P0 to completion → finishes at 7.
- t=7: P1(4), P2(1), P3(4) all arrived. Shortest = P2. Run P2 → finishes at 8.
- t=8: P1(4), P3(4). Tie broken by arrival → P1. Finishes at 12.
- t=12: P3 runs → finishes at 16.
Gantt Chart
| P0 | P2 | P1 | P3 | 0 7 8 12 16Waiting Time
Process Completion Arrival Burst Waiting Time P0 7 0 7 0 P1 12 2 4 6 P2 8 4 1 3 P3 16 5 4 7 $$\text{Average WT (SJF)} = \frac{0 + 6 + 3 + 7}{4} = \frac{16}{4} = \boxed{4.0 \text{ ms}}$$
Summary
Algorithm Average Waiting Time SRTN (Preemptive) 3.0 ms SJF (Non-Preemptive) 4.0 ms - 75 marksImplementing FilesHideAnswer
Discuss the advantages disadvantages of implementing file system using Linked List. [5]
In a linked list allocation of a file system, each file is stored as a linked list of disk blocks. Each block contains a pointer to the next block of the file. The directory entry holds the address of the first block, and each block poin...
- 85 marksNumericalPage Replacement AlgorithmsHideAnswer
Consider the page references 7,0,1,2,0,3,0,4,2,3,0,3,2. Find the number of page fault using OPR and FIFO, with 4 page frame. [5]
- Reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2 (13 references) - Number of frames: 4 --- Replace the page not needed for the longest time in the future. Ref Frames Fault? --------------------- 7 7 F 0 7,0 F 1 7,0,1 F 2 7,0,1,2...
- 95 marksDMA OperationHideAnswer
Describe the working mechanism of DMA. [5]
DMA (Direct Memory Access) is a hardware mechanism that allows I/O devices to transfer data directly to or from main memory without involving the CPU for each byte of the transfer. This frees the CPU to perform other tasks during data tr...
- 105 marksControllersHideAnswer
What is the task of disk controller? List some drawback of segmentation. [5]
--- A disk controller is a hardware component that acts as an interface between the CPU/memory and the physical disk drive. Its main tasks are: 1. Receiving Commands from CPU: The disk controller accepts read/write commands from the CPU ...
- 115 marksVirtual memoryHideAnswer
Write the structure and advantages of TLB. [5]
--- TLB is a special high-speed hardware cache (associative memory) used to speed up virtual-to-physical address translation in a paging system. It stores recently used page table entries to avoid repeated access to the main memory page ...
- 125 marksConcept of Locality of ReferenceHideAnswer
Why do we need the concept of locality of reference? List the advantages and disadvantages of Round Robin algorithm. [5]
--- Locality of Reference refers to the tendency of a processor to access the same set of memory locations repetitively over a short period of time. It is the basis for the design of cache memory and virtual memory systems. 1. Basis for ...