CSC264 · TU past paper
Operating Systems 2081 question paper
The complete TU 2081 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 marksSegmentationHideAnswer
Explain the translation of logical address into physical address using segment table with necessary diagram. List advantages and disadvantages of segmentation.[10]
Segmentation is a memory management technique in which memory is divided into variable size parts. Each part is known as a segment, which can be allocated to a process. The details about each segment are stored in a table called the segm...
- 210 marksNumericalDisk SchedulingHideAnswer
Find the seek time using SCAN, C-SCAN, Look and C-Look disk scheduling algorithms for processing the following request queue: 35, 70, 45, 15, 65, 20, 80, 90, 75, 130. Suppose the disk has tracks numbered from 0 to 150 and assume the disk arm to be at 30 and moving outward.[10]
Disk Scheduling Algorithms - Verified Solution
Given Data
- Request Queue: 35, 70, 45, 15, 65, 20, 80, 90, 75, 130
- Track range: 0 to 150
- Initial head position: 30
- Direction: Outward (toward higher tracks)
Sorted requests: 15, 20, 35, 45, 65, 70, 75, 80, 90, 130
1. SCAN
Head moves outward to 150, then reverses to service lower requests.
Order: 30 → 35 → 45 → 65 → 70 → 75 → 80 → 90 → 130 → 150 → 20 → 15
Total distance = (150 − 30) + (150 − 15) = 120 + 135 = 255 tracks
2. C-SCAN
Head moves outward to 150, jumps to 0, then continues servicing.
Order: 30 → 35 → ... → 130 → 150 → 0 → 15 → 20
Total = (150 − 30) + (150 − 0) + (20 − 0) = 120 + 150 + 20 = 290 tracks
(Equivalently, summing the individual steps: 5+10+20+5+5+5+10+40+20+150+15+5 = 290.)
3. LOOK
Head moves outward only to the last request (130), then reverses.
Order: 30 → 35 → ... → 130 → 20 → 15
Total = (130 − 30) + (130 − 15) = 100 + 115 = 215 tracks
4. C-LOOK
Head moves outward to last request (130), jumps to lowest request (15), continues outward.
Order: 30 → 35 → ... → 130 → 15 → 20
Movement From To Distance 1 30 35 5 2 35 45 10 3 45 65 20 4 65 70 5 5 70 75 5 6 75 80 5 7 80 90 10 8 90 130 40 9 130 15 115 10 15 20 5 Total = (130 − 30) + (130 − 15) + (20 − 15) = 100 + 115 + 5 = 220 tracks
Summary
Algorithm Seek Time (tracks) SCAN 255 C-SCAN 290 LOOK 215 C-LOOK 220 - 310 marksClassical IPC problemsHideAnswer
Explain the Sleeping Barber problem. Illustrate on how it can be solved.[10]
The Sleeping Barber Problem is a classic Inter-Process Communication (IPC) and process synchronization problem introduced by Dijkstra. It models a real-world scenario involving a barber shop and illustrates the challenges of coordinating...
- 45 marksOperating System StructuresHideAnswer
Explain microkernels and exokernels. [5]
--- A microkernel is a minimalist kernel design where only the most essential OS functions are kept in kernel (privileged) mode, and all other services are moved to user space as separate processes. - Basic inter-process communication (I...
- 55 marksNumericalMemory Allocation StrategiesHideAnswer
Consider a swapping system in which memory consists of the following hole sizes in memory order: 15 MB, 2 MB, 10 MB, 6 MB, 8 MB and 20 MB. Which hole is taken for successive segment requests of: (a) 10 MB (b) 10 MB For first fit, next fit and best fit. [5]
Memory Allocation: First Fit, Next Fit, Best Fit
Step 1 - Given Data
Holes in memory order:
Hole # Size 1 15 MB 2 2 MB 3 10 MB 4 6 MB 5 8 MB 6 20 MB Successive requests: (a) 10 MB, (b) 10 MB.
Step 2 - Solve
First Fit
Allocates the first hole large enough, scanning from the start each time.
(a) 10 MB: Hole 1 (15 MB) $\ge 10$ → allocate. Hole 1 leftover $= 15 - 10 = 5$ MB.
(b) 10 MB: Scan from start: Hole 1 (5) ✗, Hole 2 (2) ✗, Hole 3 (10) $\ge 10$ → allocate. Leftover $= 0$ MB.
Result: (a) Hole 1, (b) Hole 3.
Next Fit
Like First Fit but resumes scanning from the position of the last allocation.
(a) 10 MB: Start at Hole 1 (15) → allocate. Pointer at Hole 1, leftover 5 MB.
(b) 10 MB: Resume from Hole 1: (5) ✗, Hole 2 (2) ✗, Hole 3 (10) → allocate. Pointer at Hole 3.
Result: (a) Hole 1, (b) Hole 3.
(Since scanning resumes at the last hole which is now too small, next fit gives the same result as first fit here.)
Best Fit
Allocates the smallest hole that is large enough.
(a) 10 MB: Candidates $\ge 10$: Hole 1 (15, leftover 5), Hole 3 (10, leftover 0), Hole 6 (20, leftover 10). Smallest sufficient = Hole 3 (exact fit). Leftover 0 MB.
(b) 10 MB: Remaining candidates $\ge 10$: Hole 1 (15, leftover 5), Hole 6 (20, leftover 10). Smallest = Hole 1. Leftover 5 MB.
Result: (a) Hole 3, (b) Hole 1.
Final Comparison
Request First Fit Next Fit Best Fit (a) 10 MB Hole 1 (15 MB) Hole 1 (15 MB) Hole 3 (10 MB) (b) 10 MB Hole 3 (10 MB) Hole 3 (10 MB) Hole 1 (15 MB) - 65 marksSemaphoreHideAnswer
Explain how semaphore solves the problem of critical section. [5]
A critical section is the part of a program where shared memory or shared resources are accessed. When multiple processes/threads enter their critical sections simultaneously, a race condition occurs, producing incorrect or unpredictable...
- 75 marksHandling DeadlocksHideAnswer
How do you think deadlock can be avoided? Explain. [5]
Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. No process can proceed, release, or be preempted. --- For a deadlock...
- 85 marksInter-process CommunicationHideAnswer
Explain Inter-Process Communication in Linux. [5]
Inter-Process Communication (IPC) refers to a mechanism where the operating system allows various processes to communicate with each other, synchronize their actions, and manage shared data. It allows a specific program to handle many us...
- 95 marksFile OverviewHideAnswer
List different file structures and explain them. [5]
File Structures
A file structure defines how data is organized and stored within a file. Different types of files have different internal structures depending on their purpose and the programs that use them.
Different File Structures
1. Regular Files (User Files)
Regular files contain user information. They are the most common type of file and are generally of two subtypes:
a) ASCII Files
- Consist of lines of text.
- Each line is terminated by a carriage return or newline character.
- Can be displayed and printed directly.
- Can be created and edited by any ordinary text editor.
- Example:
.txtfiles, source code files.
b) Binary Files
- Consist of a sequence of bytes only.
- They have some internal structure known only to the programs that use them.
- Cannot be read directly as plain text.
- Example: Executable files (compiled programs), object files.
2. Directory Files
- These are system files used for maintaining the structure of the file system.
- A directory file keeps track of the files contained within it, storing their names, identifiers, and locations.
- They form the hierarchical tree structure of the file system.
3. Character Special Files
- Related to Input/Output (I/O) operations of the computer.
- Used to model serial I/O devices such as terminals, printers, and network interfaces.
- They do not store data permanently; instead, they represent device streams.
Summary Table
File Structure Description Example ASCII File Text lines, human-readable .txt, source codeBinary File Byte sequences, internal structure Executable, .exeDirectory File Maintains file system structure Folders/directories Character Special File Models serial I/O devices Terminals, printers
Conclusion
Different file structures serve different purposes in an operating system. Regular files (ASCII and binary) store user data, directory files organize the file system hierarchy, and character special files provide an interface to hardware I/O devices. Understanding these structures is essential for effective file system management.
- 105 marksNumericalProcess SchedulingHideAnswer
Calculate the average waiting time and turnaround time using priority algorithm (Priority 1 being the highest) for the given scenario:
$$\begin{array}{|c|c|c|c|} \hline \text{PID} & \text{Burst Time} & \text{Arrival Time} & \text{Priority} \ \hline A & 3 & 0 & 3 \ B & 2 & 2 & 3 \ C & 4 & 3 & 2 \ D & 2 & 3 & 1 \ \hline \end{array}$$
[5]
Priority Scheduling (Non-Preemptive) - Average WT and TAT
Step 1 - Extract: Given Data
PID Burst Time Arrival Time Priority A 3 0 3 B 2 2 3 C 4 3 2 D 2 3 1 Priority 1 = highest. Assume non-preemptive priority scheduling.
Step 2 - Solve
Execution Order
- t = 0: Only A available → A runs 0 to 3.
- t = 3: Ready = B (P3), C (P2), D (P1). Highest priority = D → D runs 3 to 5.
- t = 5: Ready = B (P3), C (P2). Higher priority = C → C runs 5 to 9.
- t = 9: Only B remains → B runs 9 to 11.
Gantt Chart
| A | D | C | B | 0 3 5 9 11Completion, Turnaround, Waiting Times
TAT = CT − AT, WT = TAT − BT
PID AT BT CT TAT = CT−AT WT = TAT−BT A 0 3 3 3 0 B 2 2 11 9 7 C 3 4 9 6 2 D 3 2 5 2 0 Averages
$$\text{Avg TAT} = \frac{3 + 9 + 6 + 2}{4} = \frac{20}{4} = 5 \text{ ms}$$
$$\text{Avg WT} = \frac{0 + 7 + 2 + 0}{4} = \frac{9}{4} = 2.25 \text{ ms}$$
Final Result
Metric Value Average Turnaround Time 5 ms Average Waiting Time 2.25 ms - 115 marksMemory Mapped IOHideAnswer
Explain memory-mapped I/O. [5]
Memory-mapped I/O is a method of performing input/output operations in which each I/O device's control register is assigned a unique memory address, to which no actual RAM is assigned. In most systems, these assigned addresses are locate...
- 125 marksVirtual memoryHideAnswer
Write short notes on: a. Virtual Memory b. Race Condition [5]
Short Notes: Virtual Memory and Race Condition
a. Virtual Memory (2.5 marks)
Virtual Memory is a memory management technique in which the operating system uses a portion of the hard disk as an extension of RAM, thereby increasing the effective size of usable memory beyond the physical RAM available.
Key Concepts:
- When the kernel needs memory for a new process but RAM is full, it writes the contents of a currently unused block of memory to the hard disk. This process is called swapping out.
- When the original contents are needed again, they are read back into memory (swapped in).
- The portion of the hard disk used for this purpose is called swap space.
Working Mechanism:
- A segment number is used to find the segment descriptor.
- A check is made whether the segment's page table is in memory; if not, a segment fault occurs.
- The page table entry for the requested virtual page is examined; if the page is not in memory, a page fault is triggered.
- If the page is in memory, the main memory address is extracted from the page table entry.
- The offset is added to the page origin to give the final main memory address, and the read/write takes place.
Advantages and Disadvantages:
Advantage Disadvantage Programs larger than physical RAM can run Disk access is slower than RAM, reducing speed More processes can be accommodated Excessive swapping (thrashing) degrades performance In Linux, swap space can be a swap partition (faster) or a swap file within the normal file system.
b. Race Condition (2.5 marks)
A Race Condition is a situation that occurs when two or more processes (or threads) read or write some shared data concurrently, and the final result depends on the precise order in which the processes execute.
Key Points:
- Race conditions typically occur inside a critical section, where multiple threads access shared resources.
- The result of execution differs according to the order in which threads or processes run, making the output unpredictable and incorrect.
Example Scenario:
- Two processes share a common variable (e.g., a counter).
- Process A reads the value, and before it writes back the updated value, Process B also reads the same old value.
- Both processes write their result, and one update is lost, producing an incorrect final value.
Illustration:
Shared variable: count = 5 Process A: reads count (5), computes count+1 = 6 Process B: reads count (5), computes count+1 = 6 <-- reads before A writes Process A: writes count = 6 Process B: writes count = 6 <-- should be 7, but is 6 (incorrect!)Prevention:
Race conditions can be prevented using synchronization mechanisms such as:
- Mutex locks
- Semaphores
- TSL (Test and Set Lock) instruction -- a shared lock variable is set to 1 before entering the critical section and reset to 0 after leaving, ensuring mutual exclusion.
In summary, race conditions arise due to uncontrolled concurrent access to shared data, and must be carefully managed to ensure correctness of programs.