BSc CSIT (TU) Science Operating System (BSc CSIT, CSC259) Question Paper 2075 Nepal
This is the official BSc CSIT (TU) (Science stream) Operating System (BSc CSIT, CSC259) question paper for 2075, as set in the regular annual examination. It carries 60 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this Operating System (BSc CSIT, CSC259) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BSc CSIT (TU) Operating System (BSc CSIT, CSC259) exam or solving previous years' question papers, this 2075 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
What is a resource allocation graph? Explain the process of detecting deadlock when there is a single instance of each resource type with a suitable example.
Resource Allocation Graph (RAG)
A Resource Allocation Graph is a directed graph used to describe the state of allocation of resources to processes in a system. It is used to detect and reason about deadlocks.
Components:
- Vertices are of two types:
- Process nodes () drawn as circles.
- Resource nodes () drawn as rectangles; dots inside a rectangle represent the number of instances of that resource.
- Edges are of two types:
- Request edge : process has requested resource and is waiting.
- Assignment edge : an instance of has been allocated to .
Deadlock Detection with a Single Instance per Resource
When each resource type has exactly one instance, deadlock detection reduces to a simple rule:
A deadlock exists if and only if the resource allocation graph contains a cycle.
With multiple instances a cycle is only a necessary condition, but with single instances a cycle is both necessary and sufficient.
Detection algorithm: Construct a wait-for graph by removing resource nodes from the RAG and collapsing edges: if and , add an edge . Then run a cycle-detection (DFS) on the wait-for graph; any cycle indicates deadlock.
Example
Consider processes and single-instance resources :
- (R1 held by P1)
- (P1 requests R2)
- (R2 held by P2)
- (P2 requests R3)
- (R3 held by P3)
- (P3 requests R1)
Following the edges we get the cycle:
Since a cycle exists and each resource has a single instance, the system is deadlocked: waits for held by , waits for held by , and waits for held by — a circular wait that can never resolve.
If instead had not requested (no edge ), the graph would be acyclic and no deadlock would exist.
Explain the Critical Section problem. Describe Peterson's solution and the use of semaphores to achieve process synchronization.
The Critical Section Problem
A critical section is a segment of code in which a process accesses shared resources (variables, files, devices). When multiple processes run concurrently, uncontrolled access to such shared data causes race conditions. The critical-section problem is to design a protocol that processes use to cooperate, ensuring correct execution.
A correct solution must satisfy three requirements:
- Mutual Exclusion — at most one process executes in its critical section at a time.
- Progress — if no process is in its critical section, only the processes contending may decide who enters next, and this decision cannot be postponed indefinitely.
- Bounded Waiting — there is a bound on how many times other processes enter their critical sections after a process requests entry and before it is granted (no starvation).
The general structure of each process is:
do {
entry section
critical section
exit section
remainder section
} while (true);
Peterson's Solution
Peterson's solution is a classic software solution for two processes ( and ). It uses two shared variables:
int turn;— whose turn it is to enter.boolean flag[2];—flag[i]is true if wants to enter.
Code for process (where j = 1 - i):
do {
flag[i] = true;
turn = j;
while (flag[j] && turn == j); // busy wait
// critical section
flag[i] = false;
// remainder section
} while (true);
sets its flag and politely gives the turn to . It enters only if does not want in (!flag[j]) or it is 's turn. This satisfies mutual exclusion, progress, and bounded waiting, but relies on busy waiting and only works for two processes.
Semaphores
A semaphore is an integer variable accessed only through two atomic operations:
wait(S): while (S <= 0); S = S - 1; // also called P()
signal(S): S = S + 1; // also called V()
Practical implementations avoid busy waiting by maintaining a waiting queue: wait() blocks the process when , and signal() wakes a blocked process.
Achieving synchronization: Initialize a semaphore mutex = 1. Each process wraps its critical section:
wait(mutex);
// critical section
signal(mutex);
// remainder section
This guarantees mutual exclusion for any number of processes. Counting semaphores (initialized to ) control access to a pool of identical resources, while a binary semaphore (values 0/1) acts as a mutex lock.
Explain paging as a memory management technique. Discuss how logical addresses are translated to physical addresses using a page table and TLB.
Paging
Paging is a memory-management scheme that allows the physical address space of a process to be non-contiguous, eliminating external fragmentation and the need for compaction.
- Physical memory is divided into fixed-size blocks called frames.
- Logical (virtual) memory is divided into blocks of the same size called pages.
- A typical page/frame size is a power of two (e.g., 4 KB).
- When a process executes, its pages are loaded into any available frames; the OS keeps the page-to-frame mapping in a page table.
Logical-to-Physical Address Translation
The CPU generates a logical address split into two parts:
If the logical address space is and the page size is , then the high-order bits give the page number and the low-order bits give the offset .
Steps:
- Extract page number and offset from the logical address.
- Use as an index into the page table to obtain the frame number .
- Form the physical address as , i.e., concatenate frame number with offset .
The offset is unchanged because pages and frames are the same size.
Translation Look-aside Buffer (TLB)
Using only a page table requires two memory accesses per reference (one to read the page table, one for the data), which is slow. A TLB is a small, fast, fully-associative hardware cache that stores recently used (page → frame) mappings.
Address translation with TLB:
- Present page number to the TLB.
- TLB hit: frame is returned immediately; combine with offset .
- TLB miss: access the page table in memory to get , then load that mapping into the TLB for future use.
Effective Access Time (EAT): If TLB lookup takes , memory access takes , and the hit ratio is :
Example: with ns, ns, :
This is far better than the 200 ns required without a TLB on every access.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Distinguish between starvation and deadlock.
Deadlock and starvation are both situations where processes fail to make progress, but they differ fundamentally:
| Aspect | Deadlock | Starvation |
|---|---|---|
| Definition | A set of processes are permanently blocked because each holds a resource and waits for one held by another (circular wait). | A process waits indefinitely because resources are repeatedly granted to other (often higher-priority) processes. |
| Affected processes | A group, in a circular-wait chain. | Usually a single (or few) low-priority process. |
| Progress in system | The involved processes make no progress at all. | Other processes keep progressing; only the starved one does not. |
| Cause | Hold-and-wait + circular wait + mutual exclusion + no preemption. | Biased scheduling / resource allocation policy (e.g., priority scheduling, SJF). |
| Resolution | Will not resolve on its own; needs prevention, avoidance, detection & recovery. | Can be resolved by aging (gradually raising waiting processes' priority). |
| Also called | Circular wait. | Indefinite blocking / lockout. |
Key point: Every deadlock implies starvation for the involved processes, but starvation does not imply deadlock — a starved process may still eventually run.
Explain context switching and its overhead.
Context Switching
A context switch is the mechanism by which the CPU is switched from one process (or thread) to another. The kernel saves the state (context) of the currently running process and restores the state of the next scheduled process.
The context of a process is held in its Process Control Block (PCB) and includes:
- Program counter and CPU registers,
- CPU scheduling information and process state,
- Memory-management information (page tables, base/limit registers),
- I/O status and accounting information.
Steps: save current process state → PCB; update its PCB and queues; select next process via the scheduler; restore the next process's state from its PCB; resume execution.
Context switches occur on interrupts, system calls, time-slice expiry, or when a process blocks for I/O.
Overhead
Context switching is pure overhead — during the switch the CPU does no useful work for any user process:
- Time spent saving/restoring registers and PCB data.
- Cache and TLB are flushed/invalidated, so the new process suffers cache misses afterward.
- On paged systems, memory-management structures (page tables) must be reloaded.
The cost depends on hardware support (e.g., multiple register sets reduce it). Frequent context switching (e.g., a very small time quantum in Round Robin) degrades throughput, so the quantum is chosen to keep switching overhead a small fraction of the total CPU time.
What is the producer-consumer problem? Explain in brief.
Producer-Consumer (Bounded-Buffer) Problem
The producer-consumer problem is a classic synchronization problem involving two types of processes sharing a fixed-size buffer of slots:
- The producer generates data items and places them into the buffer.
- The consumer removes items from the buffer and uses them.
The challenge (synchronization conditions):
- The producer must not add to a full buffer (wait until a slot is free).
- The consumer must not remove from an empty buffer (wait until an item exists).
- The producer and consumer must not access the buffer simultaneously (mutual exclusion on the shared buffer / count).
Semaphore Solution
Three semaphores are used:
mutex = 1— mutual exclusion on the buffer.empty = N— counts empty slots.full = 0— counts filled slots.
// Producer
wait(empty); wait(mutex);
add item to buffer;
signal(mutex); signal(full);
// Consumer
wait(full); wait(mutex);
remove item from buffer;
signal(mutex); signal(empty);
This ensures the producer blocks when the buffer is full and the consumer blocks when it is empty, while mutex prevents simultaneous access. It illustrates cooperation between processes that must share a bounded buffer correctly.
Explain the Dining Philosophers problem.
Dining Philosophers Problem
The Dining Philosophers problem is a classic synchronization problem that illustrates deadlock and resource-sharing issues among concurrent processes.
Setup: Five philosophers sit around a circular table. Each philosopher alternates between thinking and eating. There are five chopsticks, one between each pair of philosophers. To eat, a philosopher needs both the chopstick to their left and the one to their right. After eating, they put both chopsticks down and resume thinking.
The chopsticks are the shared resources, and each is modeled by a semaphore:
semaphore chopstick[5] = {1,1,1,1,1};
do {
wait(chopstick[i]); // pick up left
wait(chopstick[(i+1) % 5]); // pick up right
// eat
signal(chopstick[i]);
signal(chopstick[(i+1) % 5]);
// think
} while (true);
The problem: If all five philosophers simultaneously pick up their left chopstick, each then waits forever for the right chopstick held by a neighbor — a circular wait, i.e., deadlock. There is also a risk of starvation.
Solutions:
- Allow at most four philosophers at the table at once.
- A philosopher may pick up chopsticks only if both are available (pick up inside a critical section).
- Use asymmetry: odd philosophers pick up left-then-right, even philosophers right-then-left, breaking the circular wait.
What is thrashing? How can it be prevented?
Thrashing
Thrashing is a condition in a virtual-memory system where a process (or the whole system) spends more time paging (swapping pages in and out of memory) than executing. CPU utilization drops sharply because processes are constantly waiting for pages.
Cause: It occurs when a process does not have enough frames to hold its working set (the set of pages it is actively using). Each instruction may cause a page fault, evicting a page that is needed again immediately, causing another fault — a high page-fault rate.
The vicious cycle: Low CPU utilization → OS increases the degree of multiprogramming → less memory per process → more page faults → even lower CPU utilization.
Prevention / Control
- Working-Set Model: Track each process's working set using a window of recent references; allocate enough frames to hold it, and suspend (swap out) a process if the demand exceeds available frames.
- Page-Fault Frequency (PFF) control: Monitor each process's page-fault rate; if it rises above an upper bound, allocate more frames; if it falls below a lower bound, reclaim frames.
- Reduce the degree of multiprogramming: Swap out some processes so the rest have enough frames.
- Use local page-replacement so one greedy process cannot steal frames from others, and add more physical RAM.
Differentiate between logical and physical address space.
Logical vs Physical Address Space
A logical address (also called a virtual address) is generated by the CPU during program execution. A physical address is the actual address seen by the memory unit (loaded into the memory-address register).
| Aspect | Logical Address Space | Physical Address Space |
|---|---|---|
| Definition | Set of all logical addresses generated by a program/CPU. | Set of all physical addresses corresponding to the logical addresses. |
| Generated by | CPU | Memory Management Unit (MMU) |
| Visibility | Visible to the user/program. | Not directly visible to the user. |
| Also called | Virtual address. | Real/actual memory address. |
| Existence | Conceptual; need not correspond to real RAM location. | Actual location in physical RAM. |
Relationship: At compile time and load time the logical and physical addresses are identical. With execution-time binding, they differ, and the MMU maps logical to physical at run time. In a simple base-register scheme the mapping is:
For example, with relocation register , a logical address maps to physical address .
Explain segmentation as a memory management scheme.
Segmentation
Segmentation is a memory-management scheme that supports the user's logical view of memory. A program is regarded as a collection of variable-sized segments — logical units such as main program, function, stack, array, global variables, each with a name and length — rather than one linear array of bytes.
Addressing
A logical address under segmentation is a two-tuple:
The mapping is done through a segment table; each entry has:
- Base — the starting physical address of the segment.
- Limit — the length of the segment.
Address translation:
- Use segment number to index the segment table → obtain
baseandlimit. - Check that offset ; otherwise raise a trap (addressing error / segmentation fault).
- Physical address .
Advantages and Disadvantages
- Advantages: Matches the programmer's logical view; allows protection and sharing at the segment level (e.g., share a code segment, set read/execute permissions per segment); no internal fragmentation.
- Disadvantage: Because segments vary in size, segmentation suffers from external fragmentation and may require compaction.
What is a semaphore? Differentiate between binary and counting semaphores.
Semaphore
A semaphore is a synchronization tool — an integer variable that, apart from initialization, is accessed only through two atomic (indivisible) operations:
wait(S): while (S <= 0); S = S - 1; // P(), down
signal(S): S = S + 1; // V(), up
It is used to control access to shared resources and to coordinate the execution order of concurrent processes, solving the critical-section and other synchronization problems.
Binary vs Counting Semaphore
| Aspect | Binary Semaphore | Counting Semaphore |
|---|---|---|
| Range of value | Only 0 or 1. | Any non-negative integer (unrestricted domain). |
| Purpose | Mutual exclusion (acts as a lock / mutex). | Controls access to a resource with multiple instances. |
| Initial value | Usually 1. | Usually = number of available resource instances. |
| Meaning | 1 = available, 0 = locked. | Value = number of free resource instances; negative magnitude = number of waiting processes. |
| Use case | Protect a single critical section. | Manage a pool of identical resources (e.g., printers). |
In short: a binary semaphore is a special case of a counting semaphore restricted to the values 0 and 1.
Explain the concept of a monitor in process synchronization.
Monitor
A monitor is a high-level synchronization construct that provides a convenient and safe mechanism for process synchronization, overcoming the error-prone nature of semaphores (where a misplaced wait/signal can break mutual exclusion or cause deadlock).
Definition: A monitor is an abstract data type that encapsulates:
- Shared variables (the monitor's internal data),
- Procedures/methods that operate on those variables,
- An initialization block.
Key property — automatic mutual exclusion: Only one process can be active inside the monitor at a time. The compiler/runtime enforces this, so the programmer does not place explicit locks. Other processes calling a monitor procedure are blocked until the monitor is free.
Condition variables: To allow a process to wait inside the monitor for a specific condition, monitors provide condition variables with two operations:
x.wait()— the calling process is suspended and releases the monitor until another process signalsx.x.signal()— resumes exactly one process waiting onx(if none is waiting, it has no effect).
monitor ResourceAllocator {
boolean busy;
condition x;
procedure acquire() {
if (busy) x.wait();
busy = true;
}
procedure release() {
busy = false;
x.signal();
}
initialization { busy = false; }
}
Thus monitors guarantee mutual exclusion automatically and use condition variables for finer-grained waiting/signalling, making concurrent programs easier to write correctly than with raw semaphores.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Operating System (BSc CSIT, CSC259) question paper 2075?
- The full BSc CSIT (TU) Operating System (BSc CSIT, CSC259) 2075 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
- Does the Operating System (BSc CSIT, CSC259) 2075 paper come with solutions?
- Yes. Every question on this Operating System (BSc CSIT, CSC259) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
- How many marks is the BSc CSIT (TU) Operating System (BSc CSIT, CSC259) 2075 paper?
- The BSc CSIT (TU) Operating System (BSc CSIT, CSC259) 2075 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
- Is practising this Operating System (BSc CSIT, CSC259) past paper free?
- Yes — reading and attempting this Operating System (BSc CSIT, CSC259) past paper on Kekkei is completely free.