2082

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.

Past Papers2082208020792078

Tap a question to open its answer.

  1. 110 marksNumericalUser level threadsAnswer

    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).

    ProcessesCPU Burst TimeArrival Time
    A92
    B111
    C10
    D23
    E74

    [2+8]

    User Thread vs Kernel Thread

    FeatureUser ThreadKernel Thread
    ManagementManaged by a user-level thread libraryManaged directly by the OS kernel
    Kernel awarenessKernel is unaware of themKernel is aware and schedules them
    Context switchFast, no kernel mode switchSlower, requires kernel mode switch
    BlockingOne blocking thread blocks whole processOther threads continue running
    PortabilityPortable, runs on any OSOS dependent
    ExamplePOSIX Pthreads (user), Java green threadsWindows threads, Linux kernel threads

    Given Data

    ProcessBurstArrival
    A92
    B111
    C10
    D23
    E74

    Quantum $= 2$.


    (a) FCFS

    Order by arrival: C(0), B(1), A(2), D(3), E(4).

    ProcessArrBurstStartFinishTATWT
    C010110
    B111112110
    A2912211910
    D3221232018
    E4723302619

    $$\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 30
    

    Completion / TAT / WT

    ProcessArrBurstFinishTAT = F−AWT = TAT−B
    C01110
    B111302918
    A29292718
    D32742
    E47282417

    $$\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

    MetricFCFSRound Robin (Q=2)
    Avg Turnaround Time15.417.0
    Avg Waiting Time9.411.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.

  2. 210 marksNumericalPage fault definition and occurrenceAnswer

    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.

    RefFrames (contents)Fault
    77F
    07 0F
    17 0 1F
    27 0 1 2F
    07 0 1 2Hit
    3replace 1 → 7 0 3 2F
    07 0 3 2Hit
    4replace 7 → 4 0 3 2F
    24 0 3 2Hit
    3Hit
    0Hit
    3Hit
    2Hit
    3Hit

    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.

    RefFramesFIFO QueueFault
    77[7]F
    07 0[7,0]F
    17 0 1[7,0,1]F
    27 0 1 2[7,0,1,2]F
    07 0 1 2[7,0,1,2]Hit
    3replace 7 → 0 1 2 3[0,1,2,3]F
    00 1 2 3[0,1,2,3]Hit
    4replace 0 → 1 2 3 4[1,2,3,4]F
    21 2 3 4[1,2,3,4]Hit
    31 2 3 4[1,2,3,4]Hit
    0replace 1 → 2 3 4 0[2,3,4,0]F
    32 3 4 0[2,3,4,0]Hit
    22 3 4 0[2,3,4,0]Hit
    32 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).

    RefFrames (queue oldest→newest)ActionFault
    77(0)loadF
    07(0) 0(0)loadF
    17(0) 0(0) 1(0)loadF
    27(0) 0(0) 1(0) 2(0)loadF
    07(0) 0(1) 1(0) 2(0)hit, set R(0)=1Hit
    37 is oldest, R=0 → evict 7. New: 0(1) 1(0) 2(0) 3(0)replace 7F
    00(1) 1(0) 2(0) 3(0)hit (0 already R=1)Hit
    4Oldest 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 1F
    22(1) 3(0) 0(0) 4(0)hit, set R=1Hit
    32(1) 3(1) 0(0) 4(0)hit, set R=1Hit
    02(1) 3(1) 0(1) 4(0)hit, set R=1Hit
    32(1) 3(1) 0(1) 4(0)hitHit
    22(1) 3(1) 0(1) 4(0)hitHit
    32(1) 3(1) 0(1) 4(0)hitHit

    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

    AlgorithmPage Faults
    Optimal6
    FIFO7
    Second Chance6
  3. 310 marksDevice controller definitionAnswer

    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 ...

  4. 45 marksSystem call definition and objectivesAnswer

    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(), and close().


    Summary Table

    ObjectiveExample System Call
    Process Controlfork(), exit(), wait()
    File Managementopen(), read(), write()
    Device Managementioctl(), read(), write()
    Information Maintenancegetpid(), 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.

  5. 55 marksOperating system componentsAnswer

    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...

  6. 65 marksBanker's AlgorithmAnswer

    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...

  7. 75 marksSegmentation with pagingAnswer

    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 --...

  8. 85 marksDisk error handling and formattingAnswer

    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...

  9. 95 marksFile system implementationAnswer

    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...

  10. 105 marksInterrupt definition and occurrenceAnswer

    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...

  11. 115 marksBatch systemsAnswer

    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...

  12. 125 marksVirtual machines and system protectionAnswer

    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)
    DomainFile AFile BPrinter
    D1ReadRead/Write--
    D2--ReadWrite

    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.