2080

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.

  1. 110 marksNumericalProcess SchedulingAnswer

    (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

    ProcessArrival Time (AT)Burst Time (BT)Priority
    P0051 (Lowest)
    P1134 (Highest)
    P2282
    P3363

    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:

    TriggerDescription
    System CallProcess requests an OS service (file I/O, memory allocation)
    Hardware InterruptExternal device signals CPU (keyboard, disk, timer)
    Trap / ExceptionError 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 call
    

    The 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          22
    
    ProcessATBTCTTAT = CT-ATWT = TAT-BT
    P005550
    P113874
    P22816146
    P336221913

    $$\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          22
    
    ProcessATBTCTTAT = CT-ATWT = TAT-BT
    P005550
    P113874
    P33614115
    P228222012

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

    TimeRunRemaining afterQueue state after
    0-2P03P1 arrived@1, P2@2 present; queue: P1,P2,P0 (P3@3 next)
    2-4P11during run P3@3 arrives → queue: P2,P0,P3,P1
    4-6P26queue: P0,P3,P1,P2
    6-8P01queue: P3,P1,P2,P0
    8-10P34queue: P1,P2,P0,P3
    10-11P10 → CT=11queue: P2,P0,P3
    11-13P24queue: P0,P3,P2
    13-14P00 → CT=14queue: P3,P2
    14-16P32queue: P2,P3
    16-18P22queue: P3,P2
    18-20P30 → CT=20queue: P2
    20-22P20 → CT=22empty

    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 22
    
    ProcessATBTCTTAT = CT-ATWT = TAT-BT
    P00514149
    P11311107
    P228222012
    P336201711

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

    AlgorithmAvg Waiting TimeAvg Turnaround Time
    FCFS5.75 ms11.25 ms
    Priority (non-preemptive)5.25 ms10.75 ms
    Round Robin (Q=2)9.75 ms15.25 ms
  2. 210 marksNumericalCritical SectionAnswer

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

  3. 310 marksConditions for DeadlockAnswer

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

  4. 45 marksMemory Allocation StrategiesAnswer

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

  5. 55 marksNumericalDisk SchedulingAnswer

    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 ...
  6. 65 marksInterruptsAnswer

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

  7. 75 marksImplementing FilesAnswer

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

  8. 85 marksSegmentationAnswer

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

  9. 95 marksBelady's AnomalyAnswer

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

  10. 105 marksImplementing Mutual ExclusionAnswer

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

  11. 115 marksThread vs ProcessAnswer

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

  12. 125 marksVirtual memoryAnswer

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