Top Banner Ad
BCS401 · 2025-2622 Questions

Operating system — 2025-26

Section A

2 Marks Each · 7 questions
Q1a2MUnit 1 — Operating System Structure- Layered structure
Core Concept

What is the main advantage of the layered approach to system design?

The main advantage of the layered approach is modularity. Each layer uses only the services of the layer below and offers services to the layer above, so a layer can be changed or debugged independently without affecting the rest. This makes the system easier to implement, test and extend, though extra layers add overhead.

Key Points

  • Each layer uses the one below
  • Easier debugging and modification
  • Tradeoff is performance overhead
Q1b2MUnit 2 — Inter Process Communication models and Schemes
Core Concept

What is interprocess communication? How can it be implemented?

Interprocess communication is the exchange of data and signals between processes. It can be implemented through shared memory, where processes read and write a common region with synchronisation, or through message passing, where the kernel relays messages through a port or mailbox. Pipes, sockets and remote procedure calls are common examples.

Key Points

  • Shared memory or message passing
  • Kernel may relay messages
  • Examples pipes sockets RPC
Q1c2MUnit 2 — Semaphores
Survival ModePredicted

A counting semaphore is initialized to 10. Then 6 P (wait) and 4 V (signal) operations are performed on this semaphore. What will be the resulting value of the semaphore?

Answer: A counting semaphore's integer value changes by -1 on every P (wait) and +1 on every V (signal).

  1. Initial value S = 10.
  2. After 6 P operations: S = 10 - 6 = 4.
  3. After 4 V operations: S = 4 + 4 = 8.
  4. The value never became negative here, so no process was blocked permanently. Result: The resulting semaphore value is 8.

Key Points

  • P decrements, V increments the semaphore
  • 10 - 6 = 4; 4 + 4 = 8
  • Final value = 8
Q1d2MUnit 3 — Scheduling Algorithms
Core Concept

Illustrate the reason for the convoy effect in process scheduling.

The convoy effect occurs under first come first served scheduling when a long CPU bound process occupies the processor while many short input output bound processes wait. They finish their input output quickly and queue behind the long process, so devices sit idle and the short processes all wait together like a convoy, worsening both response time and utilisation.

Key Points

  • Long process holds the CPU
  • Short processes queue behind
  • Devices idle and response worsens
Q1e2MUnit 3 — Deadlock: System model
Survival ModeRepeated

What are the necessary conditions for deadlock in an operating system?

Answer: Deadlock is a state in which a set of processes is permanently blocked because each holds a resource that another process in the set needs.

  1. System model: processes request and release resource instances (R1..Rm) of types with A instances each; a request may block the process.
  2. A deadlock exists only if all four Coffman conditions hold: mutual exclusion, hold-and-wait, no preemption and circular wait;
  3. Resource-allocation graphs show cycles for single-instance resources; with multiple instances a cycle is necessary but not sufficient.
  4. Handling strategies: prevention (break a condition), avoidance (Banker's algorithm), detection and recovery.

The system model and the four necessary conditions. Deadlock is a state in which a set of processes is permanently blocked because each holds at least one resource and is waiting to acquire a resource held by another process in the set. In the system model, processes compete for a finite set of resource types such as processors, memory, files, printers and tape drives. Each resource type may have several identical instances, and a process requests, uses and then releases a resource. A deadlock can arise only when four conditions hold simultaneously, and these are known as the Coffman conditions. Mutual exclusion means at least one resource is non sharable, so only one process can use it at a time. Hold and wait means a process is holding at least one resource while waiting to acquire additional resources held by other processes. No preemption means a resource cannot be taken away from a process while it is in use; it can be released only voluntarily by the process. Circular wait means there exists a cycle of processes in which each process is waiting for a resource held by the next process in the cycle. Because all four are necessary, breaking any one of them prevents deadlock. Resource allocation graphs are used to visualise the model: processes and resource types are nodes, request and assignment edges show ownership, and a cycle in the graph indicates deadlock when each resource type has a single instance. A good answer defines deadlock, describes the system model of processes and resource instances, lists and explains all four necessary conditions, and states that all must hold together. Mentioning a concrete example such as two processes each holding one tape drive while requesting the other makes the circular wait tangible and shows why no progress is possible.

Result: Deadlock is permanent blocking caused by a circular wait under the four necessary conditions.

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Set of processes waiting on each other's resources
  • Four Coffman conditions are necessary
  • Resource graph/Banker's for detection or avoidance
Q1f2MUnit 4 — Locality of reference
Core Concept

What is locality of reference in demand paging?

Locality of reference is the tendency of a program to access a small set of addresses repeatedly over a short interval, called temporal locality, and to access addresses close together, called spatial locality. In demand paging it explains why keeping only a few recently used pages in memory satisfies most requests and why prefetching neighbouring pages helps.

Key Points

  • Repeated recent accesses
  • Nearby addresses accessed
  • Basis of demand paging success
Q1g2MUnit 5 — Disk storage and disk scheduling
Survival Mode

Explain seek time and rotational latency while accessing the disk.

Seek time is the time to move the disk arm so the head reaches the requested track. Rotational latency is the waiting time until the desired sector rotates under the head after the track is reached. Total access time is seek time plus rotational latency plus transfer time, with seek time usually the largest component.

Key Points

  • Seek time moves head to track
  • Rotational latency waits for sector
  • Together dominate access time

Section B

7 Marks Each · 5 questions
Q2a7MUnit 1 — Operating System services
Core Concept

The services and functions provided by an operating system can be divided into two main categories. Briefly describe the two categories and discuss how they differ.

Answer: OS services fall into two broad groups.

  1. User-oriented services: user interface (CLI/GUI), program execution, file and device manipulation, information maintenance, communication and error/accounting information.
  2. System-oriented services: resource allocation, process management, memory and file management, protection, security, accounting, networking and system calls that kernel modules use.
  3. Difference: the first group is visible to users and makes the system convenient; the second operates internally to keep the system efficient, fair and secure.

Services the operating system offers. The services provided by an operating system are commonly divided into two broad categories. The first category consists of services that help the user, including the user interface, program execution, input and output operations, file system manipulation, communications and error detection. Program execution means loading a program into memory and running it; input output operations include both files and devices; communications let processes exchange information over a network; and error detection monitors hardware and software faults and reports them. The second category consists of services that make the system efficient and secure for multiple users, including resource allocation, accounting, protection and security. Resource allocation assigns processors, memory, files and devices to the processes that request them; accounting records how much of each resource a user or job consumed for billing or statistics; protection prevents unauthorised access to resources; and security defends against external threats such as viruses and unauthorised network access. The two categories differ in purpose: the first makes the machine convenient and usable for an individual, while the second protects and coordinates the shared environment so that many users and programs coexist safely. Some services appear in both lists depending on viewpoint, but the user helping versus system protecting distinction is the standard way to organise them. A good answer names both categories, lists at least three services under each with a one line explanation, and states clearly how their goals differ. Mentioning that a command line interface and a graphical interface are alternative forms of the same user interface service shows that the list describes functions rather than particular implementations.

Result: User services improve usability; system services manage resources and protect the system.

S={0,1}∗S = \{0, 1\}^*
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Two categories: user-oriented and system-oriented
  • User: UI, execution, files, I/O, communication
  • System: allocation, protection, accounting, scheduling
Q2b7MUnit 3 — Process Control Block (PCB)
Predicted

Describe the actions taken by a kernel to context-switch between processes.

Answer: A context switch is the kernel operation of saving one process's state and loading another's.

  1. The running process is interrupted (timer, system call or I/O wait) and enters kernel mode.
  2. The kernel saves the current process's PC, program status word, registers and stack pointer into its PCB, updates its state (ready or waiting) and accounting data.
  3. The scheduler selects the next ready process; its PCB is loaded: registers, address-space/page-table pointer (often a TLB flush) and state set to running.
  4. Control returns to the new process at its saved PC.

Changing which process runs. A context switch is the operation by which the operating system stops running one process and starts running another. It is triggered when the running process blocks for input output, when its time quantum expires, when a higher priority process becomes ready, or when an interrupt occurs. The kernel first saves the context of the current process into its process control block. This includes the program counter, the general purpose registers, the stack pointer, the processor status word and any floating point or vector register state that is in use. It also updates the process state from running to ready or waiting and records accounting data such as the CPU time consumed. The kernel then selects the next process from the ready queue using the scheduling algorithm, loads that process's memory map or address space by updating the page table base register and any translation lookaside buffer flush needed, restores its saved registers and program counter from its process control block, and transfers control to the restored instruction address. The new process then resumes as if it had never been stopped. The context switch is pure overhead because the processor does no useful work for the application during it, so its cost matters for performance. It can be reduced by hardware support such as multiple register sets, by keeping address space switches rare, and by choosing a larger time quantum. A good answer describes the save, select and restore sequence, names the state that is preserved, explains why the switch is overhead and mentions how the cost can be reduced. Mentioning that a context switch is different from a mode switch between user and kernel mode, which does not change processes, is a precise distinction worth including.

Result: The switch preserves all state in the PCB so execution can resume exactly where it stopped; it is pure overhead.

S={0,1}∗S = \{0, 1\}^*
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Interrupt/trap enters kernel
  • Save PC, registers, state into old PCB
  • Load new PCB/page table and resume
Q2c7MUnit 3 — Avoidance and detection
Core Concept

Consider a system consisting of mm resources of the same type being shared by nn processes. A process can request or release only one resource at a time. Show that the system is deadlock free if the following two conditions hold: i. The maximum need of each process is between one resource and mm resources. ii. The sum of all maximum needs is less than m+nm + n.

Answer: Assume toward contradiction that the system is deadlocked.

  1. In deadlock every process waits for one resource, so each process holds fewer resources than its maximum need: need_i = max_i - held_i >= 1.
  2. Summing over all n processes: sum(max_i) >= sum(held_i) + n.
  3. Since at most m resources exist, sum(held_i) <= m, and the hypothesis says sum(max_i) < m + n.
  4. Combining gives sum(held_i) + n <= sum(max_i) < m + n, hence sum(held_i) < m. Therefore at least one resource instance is free.
  5. Because each waiting process requests only one instance and that instance is free, the request can be granted, contradicting deadlock.

Proving a system cannot deadlock. The claim is that a system with m identical resources shared by n processes is deadlock free if every maximum need lies between one and m and the sum of all maximum needs is less than m plus n. The proof proceeds by contradiction. Suppose the system is deadlocked. Then every process is holding some resources and waiting for more, so let a_i be the number currently allocated to process i and n_i its maximum need. Because it is waiting, a_i is strictly less than n_i, and because needs are integers this means a_i is at most n_i minus one. Summing over all processes gives the total allocated resources at most the sum of maximum needs minus n. By the given condition, the sum of maximum needs is less than m plus n, so the total allocated is less than m. Since there are only m resources in total, at least one resource must still be free and unallocated. But if a resource is free, some process that is waiting for resources could be given it, and that process is not forced to wait while a resource it can use sits idle. More rigorously, in a deadlocked state no process can proceed, which requires all m resources to be held by processes that are all waiting; that would make the total allocated equal to m. The inequality shows total allocated is strictly less than m, which contradicts the assumption that all resources are held in a deadlock. Therefore no deadlocked state can exist and the system is deadlock free. A good answer sets up the notation, states the contradiction assumption, derives the inequality on total allocation, exposes the contradiction with the availability of a free resource and concludes. Mentioning that the result is essentially a resource based version of the banker's safety argument and that the condition is sufficient but not necessary shows mathematical maturity.

Result: The two conditions guarantee a non-deadlocked state; the system is always deadlock-free.

T(n)=2T(n/2)+nT(n) = 2T(n/2) + n
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Assume deadlock: need_i >= 1 for all processes
  • Sum(held) + n <= Sum(max) < m + n
  • Sum(held) < m gives a free instance, contradiction
Q2d7MUnit 4 — Paging
Core Concept

Explain the working of the Translation Lookaside Buffer (TLB) along with the page table in address translation, with a neat diagram.

Answer: A TLB is a small, fast associative cache of recent (page number, frame number) translations; the page table in main memory holds the full mapping.

  1. CPU generates a logical address <p, d>.
  2. The TLB is searched associativeley for p. On a hit, the frame number f is available immediately; physical address = f x page_size + d.
  3. On a miss, the page table is consulted (using the page-table base register), the frame is found and the (p, f) entry is inserted into the TLB, evicting an old entry if full.
  4. If the page is not resident, a page fault occurs: the OS loads it, updates the page table and retries.
  5. Diagram: Logical address -> [TLB: hit/miss] -> Page table -> Physical address -> Cache/Main memory.

Speeding address translation with a TLB. Every logical address generated by a process must be translated to a physical address. A naive scheme consults the page table in main memory for every memory reference, which doubles memory traffic and is too slow. The translation lookaside buffer, or TLB, is a small, fast, associative cache inside the memory management unit that stores the most recently used page table entries. Each entry holds a tag with the page number, the corresponding frame number and protection bits. On a memory reference the hardware searches the TLB in parallel for the page number. On a hit, the frame number is combined with the unchanged page offset to form the physical address immediately. On a miss, the hardware or operating system walks the page table in main memory, obtains the frame number, updates the TLB, possibly evicting an existing entry by a replacement policy such as least recently used, and then repeats the translation. Because programs exhibit locality, a small TLB of perhaps sixty four to a few thousand entries gives hit rates above ninety nine percent, so the average translation cost stays close to the hit time. A context switch changes the address space, so the TLB must be flushed or tagged with an address space identifier to avoid using stale translations for a different process. A good answer explains the address split into page number and offset, describes the hit and miss paths, includes a diagram showing logical address to TLB to page table to physical address, explains why locality makes the TLB effective and mentions flushing on context switch. Mentioning the effective access time formula with hit ratio and miss penalty shows the performance impact quantitatively.

Result: The TLB avoids one memory access per translation; hit ratio h gives effective access time ~ hc + (1-h)(c+m).

S={0,1}∗S = \{0, 1\}^*
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.
Address translation with a TLB and page table logical addresspage + offset TLB (associative)tag page = frame page table in RAMone entry per page physical addressframe + offset page no. miss hit on a hit the frame comes from the TLB; offset passes through unchanged TLB is flushed or tagged on a context switch to avoid stale translations

Key Points

  • TLB caches recent page-table entries
  • Hit gives frame directly; miss reads page table
  • Physical address = frame x page size + offset
Q2e7MUnit 5 — RAID. File System: File concept
Core Concept

What are the advantages of using RAID architecture in disk drive? Explain in detail.

Answer: RAID (Redundant Array of Independent Disks) combines several disks to improve performance, capacity and/or reliability.

  1. Reliability: mirroring or parity lets the array survive one or more disk failures without losing data.
  2. Performance: striping spreads data across disks so reads/writes proceed in parallel, increasing throughput.
  3. Capacity/availability: several disks appear as one large logical volume; hot spares and rebuilding improve availability.
  4. Levels: RAID 0 (striping, no redundancy), RAID 1 (mirroring), RAID 5 (striping + distributed parity), RAID 6 (double parity), nested RAID 10.

Combining disks for speed and reliability. RAID, which stands for redundant array of independent disks, combines several physical disks into one logical unit to improve performance, reliability, or both. RAID 0 uses striping, spreading data across all disks in blocks. It gives excellent throughput because multiple disks work in parallel and uses the full capacity, but it provides no redundancy, so the failure of any disk loses all data. RAID 1 uses mirroring, writing identical data to two or more disks. It gives high read performance and survives the failure of a mirror member, but its usable capacity is only that of one disk, so the cost is high. RAID 5 uses block level striping with distributed parity. Parity for each stripe is stored on a different disk, so the array tolerates the loss of one disk and uses all but one disk's worth of capacity. Reads are fast because data is spread across disks, while writes are slower because parity must be read, computed and written. RAID 6 adds a second parity block and survives two disk failures, and RAID 10 combines mirroring and striping for both speed and safety. The general advantages of RAID are increased throughput through parallelism, fault tolerance through redundancy, and the ability to rebuild a failed disk from remaining data and parity. A good answer defines RAID, explains striping, mirroring and parity, describes RAID levels zero, one and five with capacity and fault tolerance for each, and lists the overall advantages with the tradeoff between performance, capacity and reliability. Mentioning that rebuild time and the risk of a second failure during rebuild are practical concerns shows depth.

Result: RAID is used to trade cost for higher I/O throughput and fault tolerance.

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • RAID = multiple disks as one logical unit
  • Striping improves throughput
  • Mirroring/parity provides fault tolerance

Section C

7 Marks Each · 10 questions
Q3a7MUnit 1 — Monolithic and Microkernel Systems
Core Concept

What is the main advantage of the microkernel approach to system design? How do user programs and system services interact in a microkernel architecture?

Answer: A microkernel keeps only essential mechanisms (IPC, minimal scheduling, memory primitives) in kernel mode and moves traditional services (file system, device drivers, network protocols) into user-space servers.

  1. Advantage: a faulty user-space service cannot crash the whole kernel; services are easier to add, replace and port.
  2. User programs call a service by sending a message through the microkernel to the appropriate server; the server performs the operation and replies.
  3. Monolithic kernels instead run all services in kernel mode, giving faster calls but a larger trusted code base.

Keeping the kernel small. The main advantage of the microkernel approach is flexibility and reliability achieved by moving most operating system services out of the kernel and into user space. A monolithic kernel places process management, memory management, file systems and device drivers all in one large program running in privileged mode, so a bug in any driver can crash the entire system. A microkernel keeps only the essential mechanisms in privileged mode, typically low level address space management, interrupt handling, thread scheduling and basic interprocess communication, and runs file systems, drivers and other services as ordinary user processes. The main advantage is that a faulty service can fail and be restarted without bringing down the whole machine, new services can be added without modifying the kernel, and the system can be adapted to different environments by changing which user services are present. User programs interact with system services through message passing: a program sends a request message to the appropriate server process through the kernel's communication mechanism, the server performs the operation and sends a reply. The kernel acts as a message router and enforces access rights, but it does not perform the service itself. The tradeoff is performance, because each service request requires context switches and message copies that a monolithic kernel avoids with direct procedure calls. A good answer states the reliability and extensibility advantage, contrasts the two structures, explains the message passing interaction path and acknowledges the performance cost. Mentioning that modern designs often move commonly used services back into the kernel for speed shows the practical compromise.

Result: Microkernel design improves reliability, security and extensibility at the cost of extra message-passing overhead.

δ(q0,a)=q1\delta(q_0, a) = q_1
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Only minimal mechanisms in kernel mode
  • Services are user-space servers reached by IPC
  • Reliable/extensible but slower than monolithic
Q3b7MUnit 1 — Classification of Operating systems- Batch
Core Concept

Discuss the classification of operating systems and provide real-world examples for each type.

Answer: Operating systems are classified by how they accept and run work.

  1. Batch: similar jobs are collected, run sequentially without user interaction; e.g., payroll processing (IBM OS/360).
  2. Interactive/time-sharing: many users get quick response through time slices; e.g., UNIX, Linux shells.
  3. Real-time: deadlines are guaranteed; hard real-time in avionics/pacemakers, soft real-time in multimedia.
  4. Multiprocessor: several CPUs share memory for parallel work; e.g., Linux on multi-core servers.
  5. Distributed: cooperating machines appear as one system; e.g., cluster file systems.
  6. Embedded/mobile: dedicated OS such as FreeRTOS or Android.

Families of operating systems. Operating systems are classified by how they handle work and how users interact with them. A batch system collects jobs into a queue and runs them one after another without user interaction, using a resident monitor to load and run each job automatically. It maximises processor utilisation but gives no interactive feedback, and it was the earliest practical design. An interactive system allows a user to communicate directly with the running program through a terminal or graphical interface, receiving immediate responses, which suits editing, browsing and design work. A time sharing system is a multi tasking interactive system that divides processor time into short slices and switches rapidly among many users or processes, so each user perceives a dedicated machine. It adds fairness and responsiveness to multiprogramming. A multiuser system lets several users share one computer concurrently, protecting each user's files and processes, as in a Unix server. A multiprocessing or parallel system has more than one processor and can execute several processes truly simultaneously for higher throughput. Real examples make the classification concrete: early IBM mainframes with punched card job streams were batch systems; modern Linux and Windows desktops are interactive, multiuser, multitasking systems; a supercomputer running climate models is a multiprocessing system, and a web server handling thousands of sessions is a time sharing multiuser system. A good answer names each class, explains its defining behaviour, contrasts batch with interactive and time sharing, and attaches at least one real example to each class. Noting that modern general purpose systems combine several of these properties in one design is a useful closing observation.

Result: Classification is based on interaction, number of users/processors and timing constraints.

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Batch, interactive, time-sharing, real-time, multiprocessor, distributed, embedded
  • Each type optimised for a different goal
  • Examples: payroll batch, UNIX time-sharing, avionics real-time
Q4a7MUnit 3 — Scheduling Algorithms
Core Concept

Consider the set of processes with arrival time (in milliseconds) and CPU burst time (in milliseconds) shown below. None of the processes have I/O burst time. Draw the Gantt chart and calculate the Average Waiting Time and Average Turnaround Time using the preemptive Shortest Job First (SJF) scheduling algorithm. Processes: P1: Arrival Time = 0, Burst Time = 8 P2: Arrival Time = 1, Burst Time = 6 P3: Arrival Time = 2, Burst Time = 9 P4: Arrival Time = 3, Burst Time = 3 P5: Arrival Time = 4, Burst Time = 4

Answer: Preemptive SJF (shortest remaining time first) always runs the process with the smallest remaining burst.

Process Arrival Burst
P1 0 8
P2 1 6
P3 2 9
P4 3 3
P5 4 4

Gantt chart (ms): | P1 0-1 | P2 1-3 | P4 3-6 | P2 6-10 | P5 10-14 | P1 14-21 | P3 21-30 | At t=1 P2 preempts P1 (6 < 7 left); at t=3 P4 preempts P2 (3 < 4 left); at t=6 P2 (rem 4, earlier arrival) precedes P5 (4).

Process Completion Turnaround Waiting
P1 21 21 13
P2 10 9 3
P3 30 28 19
P4 6 3 0
P5 14 10 6

Working through preemptive shortest job first. In shortest remaining time first scheduling the processor always executes the ready process whose remaining CPU burst is smallest, and a newly arrived process with a shorter remaining burst preempts the current one. For the given processes, P1 arrives at time zero with burst eight and begins running. At time one P2 arrives with burst six, which is shorter than P1's remaining seven, so P1 is preempted after one unit and P2 runs. At time two P3 arrives with burst nine, which is longer than P2's remaining five, so P2 continues. At time three P4 arrives with burst three, shorter than P2's remaining four, so P2 is preempted after two units and P4 runs. At time four P5 arrives with burst four while P4 has two units left, so P4 continues and finishes at time six. The ready processes are then P2 with four left, P5 with four, P1 with seven and P3 with nine. Ties are broken in arrival order, so P2 runs from six to ten and P5 from ten to fourteen. P1 then runs from fourteen to twenty one and P3 from twenty one to thirty. The Gantt chart segments are P1 zero to one, P2 one to three, P4 three to six, P2 six to ten, P5 ten to fourteen, P1 fourteen to twenty one, P3 twenty one to thirty. Completion times are twenty one, ten, thirty, six and fourteen for P1 through P5. Turnaround time is completion minus arrival and waiting time is turnaround minus burst, giving waiting times of thirteen, three, nineteen, zero and six. The average waiting time is forty one divided by five, which is eight point two milliseconds, and the average turnaround time is seventy one divided by five, which is fourteen point two milliseconds. A good answer presents the Gantt chart, explains each preemption, tabulates the results and states both averages with units. Mentioning that the algorithm is optimal for average waiting time but needs burst estimates completes the discussion.

Result: Average waiting time = 41/5 = 8.2 ms; average turnaround time = 71/5 = 14.2 ms.

T(n)=2T(n/2)+nT(n) = 2T(n/2) + n
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.
Preemptive SJF (SRTF) Gantt chart P1 P2 P4 P2 P5 P1 P3 013610142130 segments: P1 0-1, P2 1-3, P4 3-6, P2 6-10, P5 10-14, P1 14-21, P3 21-30 avg waiting = 41/5 = 8.2 ms; avg turnaround = 71/5 = 14.2 ms

Key Points

  • Preemptive SJF uses shortest remaining time
  • Gantt: P1(1),P2(2),P4(3),P2(4),P5(4),P1(7),P3(9)
  • Avg waiting 8.2 ms; avg turnaround 14.2 ms
Q4b7MUnit 3 — Process Control Block (PCB)
Predicted

What is a Process Control Block? Explain its role in process management.

Answer: A Process Control Block (PCB) is the kernel's per-process record; it is created at process creation and deleted at termination.

  1. Identity/state: PID, parent PID, user ID, process state.
  2. CPU context: program counter, registers, stack pointer, priority and scheduling information.
  3. Resources: memory limits/page table, open files, I/O devices and accounting information. Role: on a context switch the kernel saves the running process into its PCB and loads the next process from its PCB; the scheduler uses priority/state fields and the memory manager uses the page-table field.

The process control block. A process is a program in execution, and the operating system must keep a data structure for every process so it can manage and resume it. That structure is the process control block, also called the task control block. It is created when a process is created and deleted when the process terminates. The PCB stores the process state, such as new, ready, running, waiting or terminated, and a process identifier that uniquely names the process. It stores the program counter, which holds the address of the next instruction, and the CPU registers, which hold the working values of the process at the moment it was last running. It also stores scheduling information such as priority, pointers to scheduling queues and the remaining time slice, memory management information such as base and limit registers or page tables, accounting information such as CPU time used and process limits, and input output status including the list of open files and allocated devices. When a process is suspended, the operating system saves its register context and state into the PCB; when the process is resumed, it restores them so execution continues exactly where it stopped. The PCB is therefore the physical embodiment of a process: a process exists as an active entity precisely because it has a PCB, while a program is a passive file on disk. A good answer defines the PCB, lists its main fields with a sentence on each, explains how it supports context switching, and distinguishes a process from a program. Mentioning that the PCB is stored in a protected kernel area that user processes cannot modify highlights why the information is trustworthy.

Result: The PCB makes it possible to suspend and resume a process and to manage its resources safely.

T(n)=2T(n/2)+nT(n) = 2T(n/2) + n
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • PCB = kernel data structure for a process
  • Fields: PID, state, PC/registers, memory, files, priority
  • Used for context switching and resource management
Q5a7MUnit 2 — Semaphores
Core Concept

What do you mean by critical section? How can a semaphore be used to ensure synchronization in a critical section? Each process PiP_i (i=1,2,…,9i = 1, 2, \dots, 9) is coded as follows: \n\textbf{Repeat} \n P(mutex)P(\text{mutex}); critical section; V(mutex)V(\text{mutex}) \n\textbf{Forever} \nThe code for P10P_{10} is identical except that it uses V(mutex)V(\text{mutex}) in place of P(mutex)P(\text{mutex}). What is the largest number of processes that can be inside the critical section at any moment? Explain.

Answer: A critical section is a part of a program where a process accesses a shared resource; only one process should be inside it at a time. A semaphore is an integer with atomic P (wait) and V (signal) operations.

  1. Initialise mutex = 1 and wrap each critical section with P(mutex) ... V(mutex).
  2. The first process's P makes mutex 0; any later P blocks until V restores it to 1, guaranteeing mutual exclusion.
  3. In the given problem, processes P1..P9 execute P then V, so each enters one at a time. P10 executes V first, raising mutex to 2, then P lowers it to 1 and enters.
  4. While P10 is inside, another Pi can execute P (1 -> 0) and enter too; a third P would block.

Counting who gets inside. A critical section is a part of a program where a process accesses a shared resource that must not be used by another process at the same time. To guarantee mutual exclusion, a binary semaphore called mutex is initialised to one and each well behaved process executes wait on mutex before entering and signal on mutex after leaving. Wait is atomic, so only one process can decrement mutex from one to zero and enter; any other process executing wait sees zero and blocks until the first signals. In the given problem nine processes follow this correct pattern. The tenth process is different: it executes signal on mutex in place of wait; Because signal increments the semaphore, P10 never blocks on entry and can perform its critical section regardless of the mutex value. More importantly, each time P10 executes it adds a permit to the semaphore. If nine processes are executing normally and P10 executes signal once, mutex can rise above one, allowing two or more of the normal processes to pass wait simultaneously. There is no fixed upper bound imposed by the semaphore once P10 keeps adding permits, so in principle all ten processes can be inside the critical section at once. The largest number that can be inside at any moment is therefore ten, and the arrangement completely destroys mutual exclusion. This example shows that synchronisation is only as strong as the discipline of every participant; one incorrect process can defeat a correct protocol for everyone else. A good answer defines the critical section, explains wait and signal with atomicity, traces how the rogue signal raises the count and states the maximum of ten with the reason. Mentioning that a binary semaphore can be forced to one by a correcting process highlights the fragility.

Result: The largest number of processes inside the critical section at one moment is 2.

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Critical section = shared-resource code needing mutual exclusion
  • P decrements and blocks at 0; V increments
  • P10's V-first makes mutex 2, allowing two processes inside
Q5b7MUnit 3 — Avoidance and detection
Core Concept

Consider the following snapshot of a system: Allocation: T0(0012),T1(1000),T2(1354),T3(0632),T4(0014)T_0(0 0 1 2), T_1(1 0 0 0), T_2(1 3 5 4), T_3(0 6 3 2), T_4(0 0 1 4) Max: T0(0012),T1(1750),T2(2356),T3(0652),T4(0656)T_0(0 0 1 2), T_1(1 7 5 0), T_2(2 3 5 6), T_3(0 6 5 2), T_4(0 6 5 6) Available: (1520)(1 5 2 0) Answer the following questions using the banker's algorithm: i. What is the content of the matrix Need? ii. Is the system in a safe state? iii. If a request from thread T1T_1 arrives for (0,4,2,0)(0, 4, 2, 0), can the request be granted immediately?

Answer: Need = Max - Allocation.

i. Need matrix:

Process Need (A B C D)
T0 0 0 0 0
T1 0 7 5 0
T2 1 0 0 2
T3 0 0 2 0
T4 0 6 4 2

ii. Safety check with Work = (1 5 2 0): T0 (need 0) -> Work becomes (1 5 3 2); T2 (1 0 0 2) -> (2 8 8 6); T3 (0 0 2 0) -> (2 14 11 8); T4 (0 6 4 2) -> (2 14 12 12); T1 (0 7 5 0) -> (3 14 12 12). Safe sequence <T0, T2, T3, T4, T1>. iii. Request T1 = (0 4 2 0): it is <= Need(T1) and <= Available. Tentatively Available = (1 1 0 0), Alloc(T1) = (1 4 2 0), Need(T1) = (0 3 3 0). Safety: T0 -> (1 1 1 2), T2 -> (2 4 6 6), T3 -> (2 10 9 8), T4 -> (2 10 10 12), T1 -> (3 14 12 12). A safe sequence still exists.

Applying the banker's algorithm. The banker's algorithm is a deadlock avoidance scheme that tests whether a requested allocation leaves the system in a safe state. A state is safe if there exists a sequence of all processes such that each can obtain its remaining needs from the resources currently available plus those released by earlier processes in the sequence. The algorithm maintains the allocation matrix of resources currently held, the maximum matrix of resources each process may ever need, and the need matrix obtained by subtracting allocation from maximum. It also keeps an available vector of free resources. Safety is tested by initialising a work vector to available and repeatedly finding a process whose need is no greater than work; when found, its allocation is added to work and it is marked finished. If every process can be finished, the state is safe. For a request, the algorithm first checks that the request does not exceed the process's need and does not exceed available, then tentatively grants it and runs the safety test; the request is granted only if the resulting state is safe. In the tape drive example, P1 holds three of seven maximum, P2 holds one of six, and P3 holds three of five, so their needs are four, five and two. With three drives free, only P3 can finish first, releasing three to make six free, then P1 or P2 can finish, so a safe sequence exists and the system is safe and not deadlocked. In the larger snapshot problem, the need matrix is computed by subtraction, a safe sequence is found from the available vector, and the request from T1 is checked for need and availability and then tested for safety before being granted. A good answer states the data structures, performs the subtraction, walks through the safety sequence and states the conclusion with reasoning. Mentioning the distinction between a safe state and deadlock, where deadlock implies unsafe but unsafe does not necessarily imply deadlock yet, is important.

Result: Need as above; the system is safe; the request of T1 can be granted immediately.

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Need = Max - Allocation matrix
  • Safe sequence <T0,T2,T3,T4,T1>
  • Request (0,4,2,0) passes safety test -> granted
Q6a7MUnit 4 — Multiprogramming with variable partitions
Core Concept

Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and 600 KB (in order), how would the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB, and 426 KB (in order)? Which algorithm makes the most efficient use of memory?

Answer: Partitions in order: 100, 500, 200, 300, 600 KB; processes 212, 417, 112, 426 KB.

First-fit: 212 -> 500 (left 288); 417 -> 600 (left 183); 112 -> 288 (left 176); 426 -> no fit. Best-fit: 212 -> 300 (left 88); 417 -> 500 (left 83); 112 -> 200 (left 88); 426 -> 600 (left 174). All four placed. Worst-fit: 212 -> 600 (left 388); 417 -> 500 (left 83); 112 -> 388 (left 276); 426 -> no fit.

Allocating memory in variable sized blocks. Multiprogramming with variable partitions allocates main memory dynamically to the exact size of each process rather than dividing it into fixed equal blocks. When a process is admitted, the operating system finds a free hole large enough and carves out a partition of the required size, leaving the remainder as a new hole. When a process terminates, its partition is returned to the pool of free memory and may be merged with adjacent holes to form a larger one. The operating system tracks memory with a list or bitmap of allocated and free blocks, and chooses a hole using a placement strategy such as first fit, best fit or worst fit. First fit takes the first adequate hole and is fast; best fit takes the smallest adequate hole and reduces leftover but can create many tiny holes; worst fit takes the largest hole and leaves a more usable remainder. Variable partitioning improves memory utilisation compared with fixed partitions because a small process does not waste a large fixed block, and it supports processes of different sizes without internal fragmentation. Its disadvantage is external fragmentation: after many allocations and releases, free memory is split into many small non contiguous holes whose total may be large but none big enough for a new process. Compaction, which shifts processes to gather free space, or paging, which allows non contiguous allocation, are the standard remedies. A good answer explains how partitions are created and freed, describes the placement strategies, states the improvement in utilisation and explains external fragmentation with its remedy. Mentioning that the choice of placement strategy affects both speed and fragmentation ties the details together.

Result: Best-fit makes the most efficient use of memory here - it is the only algorithm that places all four processes.

O(nlog⁡n)O(n \log n)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • First-fit places 212->500, 417->600, 112->288, 426 fails
  • Best-fit places all four: 300,500,200,600
  • Worst-fit fails on 426; best-fit is most efficient
Q6b7MUnit 4 — Page replacement algorithms
Core Concept

Consider the virtual page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6 on a demand paged virtual memory system running on a computer system that has a main memory size of 4 page frames which are initially empty. How many page faults will occur if the program uses: LRU and Optimal Page replacement techniques?

Answer: Reference string: 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3,6; 4 frames. LRU: frames after each reference: [1], [1,2], [1,2,3], [1,2,3,4], hit 2, hit 1, [4,2,1,5], [2,1,5,6], hit 2, hit 1, hit 2, [6,1,2,3], [1,2,3,7], [2,3,7,6], hit 3, hit 2, [6,3,2,1], hit 2, hit 3, hit 6. Faults at references 1,2,3,4,7,8,12,13,14,17 = 10 faults. Optimal: keep pages used farthest in future: initial 4 faults, hits at 5,6, fault 7 (replace 4), fault 8 (replace 5), hits 9-12, fault 13 (replace 1), hits 14-16, fault 17 (replace 7), hits 18-20 = 8 faults.

Deciding which page to evict. When a page fault occurs and all frames are occupied, the operating system must choose a victim page to remove. Page replacement algorithms differ in which page they select and in how many faults they produce for a given reference string. The optimal algorithm, also called MIN, replaces the page whose next use is furthest in the future; it produces the fewest possible faults but cannot be implemented in general because future references are unknown, so it serves as a benchmark. First in first out replaces the oldest page, which is simple but ignores usage and suffers Belady's anomaly, where more frames can paradoxically cause more faults. Least recently used replaces the page that has not been used for the longest time, approximating the optimal choice using recent history; it performs well but needs hardware support such as a reference bit, a stack or counters to be efficient. Clock or second chance uses a circular list and a reference bit, giving a cheap approximation to least recently used. Counting based algorithms such as least frequently used keep a counter of accesses. For a reference string processed with three or four frames, the fault count is obtained by stepping through the string, marking hits, and on each miss selecting the victim according to the rule, counting every miss as a fault. A good answer explains the goal of minimising faults, describes optimal, first in first out and least recently used, traces the given reference string with a frame table, states the fault count and notes Belady's anomaly and the fact that optimal is unrealisable. Mentioning that bringing in a page may require writing a dirty victim back to disk adds realism to the cost discussion.

Result: LRU = 10 page faults; Optimal = 8 page faults (Optimal is lower, as expected).

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • LRU evicts least recently used page -> 10 faults
  • Optimal evicts farthest-future-use page -> 8 faults
  • 4 frames, 20 references
Q7a7MUnit 5 — Disk storage and disk scheduling
Survival ModePredictedRepeated

Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121, 191, 87, 11, 92, 10. The head is initially at cylinder number 63, moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. What is the total head movement (in number of cylinders) incurred while servicing these requests if C-SCAN and C-LOOK disk scheduling algorithms are used?

Answer: Queue = 47, 38, 121, 191, 87, 11, 92, 10; head starts at 63 moving upward; cylinders 0-199. C-SCAN: service upward 87, 92, 121, 191, go to 199, wrap to 0, then service 10, 11, 38, 47. Movement = (87-63)=24 + (92-87)=5 + (121-92)=29 + (191-121)=70 + (199-191)=8 + (199-0)=199 + 10 + 1 + 27 + 9 = 382 cylinders. C-LOOK: service upward 87, 92, 121, 191, then jump directly to the lowest pending request 10 (no travel to 199/0), then 11, 38, 47. Movement = 24 + 5 + 29 + 70 + (191-10)=181 + 1 + 27 + 9 = 346 cylinders.

Reducing disk head movement. A magnetic disk stores data on concentric tracks divided into sectors, and a read or write requires moving the head to the correct track and waiting for the sector to rotate under it. Because seek time dominates, disk scheduling algorithms choose the order in which pending requests are serviced to minimise total head movement. First come first served handles requests in arrival order, which is fair but can move the head erratically. Shortest seek time first services the nearest request next, reducing movement but risking starvation of requests at the far end when new near requests keep arriving. SCAN, or the elevator algorithm, moves the head in one direction servicing all requests on the way, reverses at the end of the disk, so it bounds starvation. C-SCAN moves only in one direction, returning to the beginning without servicing requests on the return trip, which gives more uniform response times. C-LOOK is like C-SCAN but reverses at the furthest pending request instead of travelling to the physical end of the disk, saving the empty travel to the last cylinder. For a queue on cylinders between zero and one hundred and ninety nine with the head at sixty three moving upward, C-SCAN continues upward serving all requests then wraps to zero, while C-LOOK stops at the highest pending request and jumps back to the lowest pending request. Counting the absolute differences between successive positions gives the total head movement; the C-LOOK total is smaller because it avoids travel beyond the last request. A good answer defines seek time and rotational latency, describes each algorithm with the direction of motion, traces the given queue for both C-SCAN and C-LOOK with the head positions and states the totals. Mentioning that modern solid state disks have no moving head, so these algorithms are less relevant there, is a useful modern note.

Result: C-SCAN = 382 cylinders; C-LOOK = 346 cylinders.

O(nlog⁡n)O(n \log n)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • C-SCAN goes to 199 then wraps to 0
  • C-LOOK jumps directly to lowest request
  • Total head movement: 382 and 346 cylinders
Q7b7MUnit 5 — I/O devices
Core Concept

Explain the following in detail: i. Direct Memory Access ii. Interrupt iii. Polling

Answer:

  1. Polling: the CPU repeatedly checks a device status register until the device is ready. Simple but wastes CPU cycles (busy waiting) when devices are slow.
  2. Interrupt: the device signals the CPU via an interrupt line when it needs service. The CPU finishes the current instruction, saves context, runs the Interrupt Service Routine, then resumes; no wasted polling, but interrupt overhead and priority management are required.
  3. DMA: a DMA controller transfers a whole block of data directly between device and main memory, freeing the CPU. The CPU programs the DMA controller (address, count, direction) and is interrupted only when the transfer completes.

Three ways to transfer data with devices. The processor can exchange data with input output devices in several ways. Polling, or programmed input output, has the processor repeatedly read a status register until the device signals ready, then transfer one word. It is easy to implement but wastes processor cycles in a busy wait loop. Interrupt driven input output removes the waiting: the device raises an interrupt line when it is ready, the processor finishes its current instruction, saves its context and jumps to an interrupt service routine that performs the transfer and then returns to the interrupted program. Interrupts may be maskable or non maskable, vectored or non vectored, and a priority mechanism decides which request is handled first when several arrive together. Direct memory access goes further. A DMA controller is given the starting memory address, the word count and the transfer direction by the processor. It then takes control of the buses and moves an entire block between the device and memory without processor involvement, interrupting the processor only when the whole transfer is complete. During the transfer the processor may continue other work, or it may be paused for a memory cycle in a scheme called cycle stealing. DMA is far more efficient than polling or interrupts for large transfers such as disk reads, while interrupts suit sporadic small events and polling suits very simple or very fast devices where the overhead of an interrupt would dominate. A good answer defines all three methods, explains the role of status checks, interrupt service routines and DMA controller registers, compares CPU involvement and efficiency, and gives an application for each. Mentioning that all three can coexist in one system is a useful practical note.

Result: Polling wastes CPU; interrupts notify the CPU on demand; DMA offloads bulk data transfer and interrupts only at completion.

O(nlog⁡n)O(n \log n)
Tip from Examiner: Explain the mechanism or algorithm step by step, support it with a diagram, table or worked calculation, and state the final result with clear units.

Key Points

  • Polling: CPU checks status repeatedly
  • Interrupt: device signals CPU, ISR handles it
  • DMA: controller transfers blocks, one interrupt at end