BIT204 · TU past paper
Operating Systems 2082 question paper
The complete TU 2082 exam paper for Operating Systems (BIT204), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- 110 marksNumericalUser level threadsHideAnswer
Question
Differentiate between user thread and kernel thread. Given the following information about processes, compute the average waiting time and turnaround time for FCFS and Round Robin (Quantum = 2).
Processes CPU Burst Time Arrival Time A 9 2 B 11 1 C 1 0 D 2 3 E 7 4 [2+8]
User Thread vs Kernel Thread
Feature User Thread Kernel Thread Management Managed by a user-level thread library Managed directly by the OS kernel Kernel awareness Kernel is unaware of them Kernel is aware and schedules them Context switch Fast, no kernel mode switch Slower, requires kernel mode switch Blocking One blocking thread blocks whole process Other threads continue running Portability Portable, runs on any OS OS dependent Example POSIX Pthreads (user), Java green threads Windows threads, Linux kernel threads
Given Data
Process Burst Arrival A 9 2 B 11 1 C 1 0 D 2 3 E 7 4 Quantum $= 2$.
(a) FCFS
Order by arrival: C(0), B(1), A(2), D(3), E(4).
Process Arr Burst Start Finish TAT WT C 0 1 0 1 1 0 B 1 11 1 12 11 0 A 2 9 12 21 19 10 D 3 2 21 23 20 18 E 4 7 23 30 26 19 $$\text{Avg TAT} = \frac{1+11+19+20+26}{5} = \frac{77}{5} = 15.4$$
$$\text{Avg WT} = \frac{0+0+10+18+19}{5} = \frac{47}{5} = 9.4$$
(b) Round Robin (Quantum = 2)
Enqueue rule: a newly arriving process is added to the ready queue before the just-preempted process is re-added.
Tracing:
- t=0: only C ready. Run C(1) → t=1, C done.
- t=1: B arrives, queue [B]. Run B → t=3, B rem 9. During run, A arrives at 2, D arrives at 3. Queue after adding arrivals then B: [A, D, B].
- t=3: Run A → t=5, A rem 7. E arrives at 4. Queue: [D, B, E, A].
- t=5: Run D(2) → t=7, D done. Queue: [B, E, A].
- t=7: Run B → t=9, B rem 7. Queue: [E, A, B].
- t=9: Run E → t=11, E rem 5. Queue: [A, B, E].
- t=11: Run A → t=13, A rem 5. Queue: [B, E, A].
- t=13: Run B → t=15, B rem 5. Queue: [E, A, B].
- t=15: Run E → t=17, E rem 3. Queue: [A, B, E].
- t=17: Run A → t=19, A rem 3. Queue: [B, E, A].
- t=19: Run B → t=21, B rem 3. Queue: [E, A, B].
- t=21: Run E → t=23, E rem 1. Queue: [A, B, E].
- t=23: Run A → t=25, A rem 1. Queue: [B, E, A].
- t=25: Run B → t=27, B rem 1. Queue: [E, A, B].
- t=27: Run E(1) → t=28, E done. Queue: [A, B].
- t=28: Run A(1) → t=29, A done. Queue: [B].
- t=29: Run B(1) → t=30, B done.
Gantt Chart:
C | B | A | D | B | E | A | B | E | A | B | E | A | B | E | A | B 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 28 29 30Completion / TAT / WT
Process Arr Burst Finish TAT = F−A WT = TAT−B C 0 1 1 1 0 B 1 11 30 29 18 A 2 9 29 27 18 D 3 2 7 4 2 E 4 7 28 24 17 $$\text{Avg TAT} = \frac{1+29+27+4+24}{5} = \frac{85}{5} = 17.0$$
$$\text{Avg WT} = \frac{0+18+18+2+17}{5} = \frac{55}{5} = 11.0$$
Summary
Metric FCFS Round Robin (Q=2) Avg Turnaround Time 15.4 17.0 Avg Waiting Time 9.4 11.0 Watch the Round Robin queue order: using the standard enqueue convention (new arrivals join the ready queue before the preempted process), B finishes at 30 and A at 29, giving Avg TAT = 17.0 and Avg WT = 11.0. A different enqueue order, for example running D at t = 6 to 8, gives finish times B = 29 and A = 27 instead. FCFS is unaffected.
- 210 marksNumericalPage fault definition and occurrenceHideAnswer
When does page fault occur?Given the 7 page reference strings 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3, find the number of page fault using Optimal Page Replacement, FIFO and Second Chance Replacement algorithm. Assume the size of page frame is 4.[1+9]
Page Fault and Page Replacement Algorithms
When Does a Page Fault Occur?
A page fault occurs when a process references a page that is not currently present in main memory (RAM). The CPU generates a trap, and the OS must bring the required page from secondary storage into a frame. If no free frame exists, a page replacement algorithm chooses a victim to evict.
Given Data
- Reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3
- Number of frames: 4
- Total references: 14
1. Optimal Page Replacement
Replace the page not needed for the longest time in the future.
Ref Frames (contents) Fault 7 7 F 0 7 0 F 1 7 0 1 F 2 7 0 1 2 F 0 7 0 1 2 Hit 3 replace 1 → 7 0 3 2 F 0 7 0 3 2 Hit 4 replace 7 → 4 0 3 2 F 2 4 0 3 2 Hit 3 Hit 0 Hit 3 Hit 2 Hit 3 Hit At ref 3 (index 6), page 1 is never used again → evict 1.
At ref 4, remaining future refs: 2,3,0,3,2,3. Page 7 never used again → evict 7.Optimal Page Faults = 6
2. FIFO Page Replacement
Replace the oldest loaded page.
Ref Frames FIFO Queue Fault 7 7 [7] F 0 7 0 [7,0] F 1 7 0 1 [7,0,1] F 2 7 0 1 2 [7,0,1,2] F 0 7 0 1 2 [7,0,1,2] Hit 3 replace 7 → 0 1 2 3 [0,1,2,3] F 0 0 1 2 3 [0,1,2,3] Hit 4 replace 0 → 1 2 3 4 [1,2,3,4] F 2 1 2 3 4 [1,2,3,4] Hit 3 1 2 3 4 [1,2,3,4] Hit 0 replace 1 → 2 3 4 0 [2,3,4,0] F 3 2 3 4 0 [2,3,4,0] Hit 2 2 3 4 0 [2,3,4,0] Hit 3 2 3 4 0 [2,3,4,0] Hit FIFO Page Faults = 7
3. Second Chance (Clock) Page Replacement
FIFO order maintained, but on a hit the reference bit R is set to 1. When selecting a victim, if the oldest page has R=1, clear it to 0 and move it to the back (give it a second chance); if R=0, replace it.
Notation: page(R).
Ref Frames (queue oldest→newest) Action Fault 7 7(0) load F 0 7(0) 0(0) load F 1 7(0) 0(0) 1(0) load F 2 7(0) 0(0) 1(0) 2(0) load F 0 7(0) 0(1) 1(0) 2(0) hit, set R(0)=1 Hit 3 7 is oldest, R=0 → evict 7. New: 0(1) 1(0) 2(0) 3(0) replace 7 F 0 0(1) 1(0) 2(0) 3(0) hit (0 already R=1) Hit 4 Oldest 0 has R=1 → clear to 0, move back. Next oldest 1 has R=0 → evict 1. New: 2(0) 3(0) 0(0) 4(0) replace 1 F 2 2(1) 3(0) 0(0) 4(0) hit, set R=1 Hit 3 2(1) 3(1) 0(0) 4(0) hit, set R=1 Hit 0 2(1) 3(1) 0(1) 4(0) hit, set R=1 Hit 3 2(1) 3(1) 0(1) 4(0) hit Hit 2 2(1) 3(1) 0(1) 4(0) hit Hit 3 2(1) 3(1) 0(1) 4(0) hit Hit Step detail at ref 4: clock pointer at oldest = 0 (R=1) → set R=0, advance; page 1 (R=0) → victim. Result frames = {2,3,0,4}. This matches FIFO's replacement here because giving 0 a second chance saved it.
Second Chance Page Faults = 6
Summary
Algorithm Page Faults Optimal 6 FIFO 7 Second Chance 6 - 310 marksDevice controller definitionHideAnswer
Discuss about controller and memory mapped I/O.Differentiate between interrupt based I/O and DMA based I/O.[5+5]
Note: No specific curriculum notes were found for this topic. The answer below is based on standard, correct Computer Organization and Architecture concepts as taught in BSc CSIT programs. --- (a) Controller and Memory Mapped I/O An I/O ...
- 45 marksSystem call definition and objectivesHideAnswer
Define system call? What are its objectives? [5]
System Call: Definition and Objectives
Definition
A system call is a programmatic way in which a computer program requests a service from the kernel of the operating system. It provides an interface between a user-level process and the operating system, allowing user programs to request OS services that require higher privilege levels (kernel mode) than the user mode in which normal programs run.
In simple terms, a system call is a controlled entry point into the kernel through which a running program can ask the OS to perform operations on its behalf.
Example: When a program wants to read a file, it issues a
read()system call rather than directly accessing the hardware.
Objectives of System Calls
System calls serve the following key objectives:
1. Hardware Abstraction
System calls hide the complexity of hardware from user programs. Programmers do not need to know the details of hardware devices; they simply call standard system call interfaces.
2. Protection and Security
They ensure that user programs cannot directly access hardware or critical OS resources. The OS validates each request, preventing unauthorized or harmful operations.
3. Resource Management
System calls allow the OS to manage and allocate resources (CPU, memory, I/O devices, files) in a controlled and fair manner among multiple processes.
4. Mode Switching (User Mode to Kernel Mode)
System calls provide a safe and controlled mechanism to switch from user mode to kernel mode, so that privileged instructions can be executed only under OS supervision.
5. Process Control
They allow user programs to create, terminate, and manage processes and threads (e.g.,
fork(),exec(),exit()).6. Inter-Process Communication (IPC)
System calls provide mechanisms for processes to communicate and synchronize with each other (e.g., pipes, message queues, shared memory).
7. File and I/O Operations
They provide a standard interface for file management and input/output operations such as
open(),read(),write(), andclose().
Summary Table
Objective Example System Call Process Control fork(),exit(),wait()File Management open(),read(),write()Device Management ioctl(),read(),write()Information Maintenance getpid(),alarm()Communication (IPC) pipe(),shmget()
In conclusion, system calls act as the bridge between user applications and the operating system kernel, ensuring security, abstraction, and controlled access to system resources.
- 55 marksOperating system componentsHideAnswer
Explain about operating system components in brief. [5]
An operating system is made up of several key components that work together to manage hardware and software resources. The main components are described briefly below: --- - A process is a program in execution. - The OS is responsible fo...
- 65 marksBanker's AlgorithmHideAnswer
Discuss about working mechanism of banker’s algorithm. [5]
The Banker's Algorithm, proposed by Dijkstra, is a deadlock avoidance algorithm used in operating systems. It is named after a banking system where a banker grants loans only if the total amount requested does not exceed available resour...
- 75 marksSegmentation with pagingHideAnswer
Why do we prefer segmentation with paging? Explain. [5]
Both pure segmentation and pure paging have their own limitations. To overcome these limitations, modern operating systems combine both techniques into a hybrid scheme called Segmentation with Paging. --- Pure Paging Pure Segmentation --...
- 85 marksDisk error handling and formattingHideAnswer
Describe about error handling and formatting in disk management. [5]
Note: The reference notes did not contain specific content on this topic. The following answer is based on standard Operating Systems concepts as taught in BSc CSIT curriculum. --- Disk formatting is the process of preparing a disk for u...
- 95 marksFile system implementationHideAnswer
Explain about file system and directory system implementation. [5]
Note: Reference notes were not available for this topic. The following answer is based on standard Operating Systems curriculum as taught in BSc CSIT. --- The file system provides a mechanism for storing and accessing both data and progr...
- 105 marksInterrupt definition and occurrenceHideAnswer
Define interrupt. Describe about device controller. [2+3]
--- An interrupt is a signal sent to the CPU by hardware or software indicating that an event needs immediate attention. When an interrupt occurs, the CPU suspends its current execution, saves its state, and transfers control to a specia...
- 115 marksBatch systemsHideAnswer
Explain about batch system and time sharing operating systems. [5]
Note: Reference notes were not available for this topic. The following answer is based on standard Operating Systems curriculum as taught in BSc CSIT. --- A batch operating system is one of the earliest types of operating systems where s...
- 125 marksVirtual machines and system protectionHideAnswer
What is virtual machine? Discuss about system protection. [2+3]
Virtual Machine and System Protection
Virtual Machine (2 marks)
A virtual machine (VM) is a software emulation of a physical computer system that provides a virtual environment in which an operating system or application can run as if it were running on dedicated physical hardware.
A virtual machine creates an illusion of a complete hardware system (including CPU, memory, storage, and network interfaces) on top of actual physical hardware. Multiple virtual machines can run simultaneously on a single physical machine, each isolated from the others.
Key characteristics:
- Each VM runs its own operating system (called guest OS)
- The underlying physical machine runs a host OS or hypervisor
- VMs are isolated from each other, providing security and stability
- Examples: VMware, VirtualBox, Hyper-V
+------------------+ +------------------+ | Guest OS 1 | | Guest OS 2 | +------------------+ +------------------+ | Virtual Machine Monitor (VMM) | +----------------------------------------+ | Physical Hardware | +----------------------------------------+
System Protection (3 marks)
System protection refers to mechanisms and policies used by an operating system to control access to resources (CPU, memory, I/O devices, files) and prevent unauthorized or accidental interference between processes and users.
Goals of System Protection:
- Prevent unauthorized access to system resources
- Ensure each process accesses only what it is permitted to
- Detect and prevent errors that could compromise system integrity
Key Concepts in System Protection:
1. Protection Domains
- A protection domain defines a set of resources and the access rights (read, write, execute) a process has over those resources.
- A process operates within a domain and can only access objects permitted in that domain.
- Domains can be associated with users, processes, or procedures.
2. Access Matrix
- An access matrix is a model for protection where:
- Rows represent domains (users/processes)
- Columns represent objects (files, devices)
- Entries define allowed operations (read, write, execute)
Domain File A File B Printer D1 Read Read/Write -- D2 -- Read Write 3. Dual Mode Operation
- Hardware support for protection through user mode and kernel mode
- Privileged instructions can only execute in kernel mode
- Prevents user processes from directly accessing hardware
4. Memory Protection
- Ensures a process cannot access memory belonging to another process or the OS
- Implemented using base and limit registers or paging/segmentation
5. CPU Protection
- Timer interrupts prevent a process from monopolizing the CPU
- The OS regains control after a set time interval
Summary:
System protection ensures controlled access, isolation, and integrity of resources, making the system reliable and secure for multiple users and processes.