BSc CSIT (TU) Science Operating System (BSc CSIT, CSC259) Question Paper 2074 Nepal
This is the official BSc CSIT (TU) (Science stream) Operating System (BSc CSIT, CSC259) question paper for 2074, 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 2074 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
What is a process? Explain the process state diagram and the role of the Process Control Block (PCB) in process management.
Process
A process is a program in execution. A program is a passive entity (a file on disk), whereas a process is an active entity with a program counter, registers, stack, data section and a set of associated resources. Each process is uniquely identified by a Process ID (PID).
Process State Diagram
During its lifetime a process passes through several states:
| State | Meaning |
|---|---|
| New | Process is being created. |
| Ready | Process is loaded in main memory and waiting to be assigned the CPU. |
| Running | Instructions are being executed on the CPU. |
| Waiting/Blocked | Process is waiting for some event (I/O completion, signal). |
| Terminated | Process has finished execution. |
Transitions (described as a diagram):
New ──admitted──▶ Ready ──scheduler dispatch──▶ Running ──exit──▶ Terminated
▲ ▲ │ │
│ └──── interrupt ───────────┘ │
I/O or event completion I/O or event wait
│ ▼
└─────────── Waiting ◀─────────────┘
- New → Ready: the process is admitted by the long-term scheduler.
- Ready → Running: the short-term scheduler (dispatcher) selects the process.
- Running → Ready: a timer interrupt / higher-priority preemption occurs.
- Running → Waiting: the process requests I/O or waits for an event.
- Waiting → Ready: the awaited event completes.
- Running → Terminated: the process finishes or is killed.
Process Control Block (PCB)
The PCB is a data structure maintained by the OS for every process; it is the repository of all information needed to manage and control that process. Key fields:
- Process state – new, ready, running, waiting, terminated.
- Process ID (PID) – unique identifier.
- Program counter – address of the next instruction.
- CPU registers – accumulators, index/stack pointers, general registers.
- CPU-scheduling information – priority, pointers to scheduling queues.
- Memory-management information – base/limit registers, page/segment tables.
- Accounting information – CPU time used, time limits, process numbers.
- I/O status information – list of open files, allocated I/O devices.
Role in process management: The PCB is the kernel's representation of a process. During a context switch, the state of the running process is saved into its PCB and the state of the next process is restored from its PCB, allowing many processes to share one CPU and to be resumed exactly where they left off.
Consider the following processes with their arrival and burst times. Compute the average waiting time and turnaround time for FCFS, SJF (preemptive/SRTN), and Round Robin (quantum = 2) scheduling algorithms.
Since the paper did not print a process table, a standard representative data set is assumed (state this assumption in the exam if the table is missing):
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 0 | 5 |
| P2 | 1 | 3 |
| P3 | 2 | 8 |
| P4 | 3 | 6 |
Turnaround Time (TAT) = Completion − Arrival; Waiting Time (WT) = TAT − Burst.
(a) FCFS (non-preemptive, order of arrival P1,P2,P3,P4)
Gantt: | P1 0-5 | P2 5-8 | P3 8-16 | P4 16-22 |
| P | Completion | TAT | WT |
|---|---|---|---|
| P1 | 5 | 5 | 0 |
| P2 | 8 | 7 | 4 |
| P3 | 16 | 14 | 6 |
| P4 | 22 | 19 | 13 |
(b) SJF Preemptive (SRTN)
Gantt: |P1 0-1|P2 1-4|P1 4-8|P4 8-14|P3 14-22|
- At t=1 remaining: P1=4, P2=3 → run P2. P2 finishes at 4.
- t=4 remaining: P1=4, P3=8, P4=6 → run P1, finishes at 8.
- t=8: P4=6, P3=8 → run P4, finishes at 14; then P3 finishes at 22.
| P | Completion | TAT | WT |
|---|---|---|---|
| P1 | 8 | 8 | 3 |
| P2 | 4 | 3 | 0 |
| P3 | 22 | 20 | 12 |
| P4 | 14 | 11 | 5 |
(c) Round Robin (quantum = 2)
Gantt: |P1 0-2|P2 2-4|P3 4-6|P4 6-8|P1 8-10|P2 10-11|P3 11-13|P4 13-15|P1 15-16|P3 16-18|P4 18-20|P3 20-22|
| P | Completion | TAT | WT |
|---|---|---|---|
| P1 | 16 | 16 | 11 |
| P2 | 11 | 10 | 7 |
| P3 | 22 | 20 | 12 |
| P4 | 20 | 17 | 11 |
Summary
| Algorithm | Avg WT | Avg TAT |
|---|---|---|
| FCFS | 5.75 | 11.25 |
| SRTN | 5.00 | 10.50 |
| RR (q=2) | 10.25 | 15.75 |
SRTN gives the minimum average waiting time; RR gives the worst here because of frequent context switches, but offers best responsiveness/fairness.
What is a deadlock? Explain the four necessary conditions for deadlock and describe deadlock avoidance using the Banker's algorithm with an example.
Deadlock
A deadlock is a situation in which a set of processes are blocked because each process is holding a resource and waiting to acquire a resource held by another process in the set, so none can ever proceed.
Four Necessary (Coffman) Conditions
All four must hold simultaneously for a deadlock to occur:
- Mutual Exclusion – at least one resource is non-sharable; only one process can use it at a time.
- Hold and Wait – a process holds at least one resource while waiting to acquire additional resources held by others.
- No Preemption – a resource cannot be forcibly taken away; it is released only voluntarily.
- Circular Wait – a circular chain exists where each process waits for a resource held by the next.
Deadlock Avoidance – Banker's Algorithm
The Banker's algorithm avoids deadlock by never entering an unsafe state. Before granting a request it checks whether the resulting state is safe (i.e. there exists a sequence in which all processes can finish).
Data structures: Available, Max, Allocation, Need = Max − Allocation.
Example (3 resource types A, B, C; total = 10, 5, 7)
| Process | Allocation (A B C) | Max (A B C) | Need (A B C) |
|---|---|---|---|
| P0 | 0 1 0 | 7 5 3 | 7 4 3 |
| P1 | 2 0 0 | 3 2 2 | 1 2 2 |
| P2 | 3 0 2 | 9 0 2 | 6 0 0 |
| P3 | 2 1 1 | 2 2 2 | 0 1 1 |
| P4 | 0 0 2 | 4 3 3 | 4 3 1 |
Total allocated = (7,2,5), so Available = (3,3,2).
Safety check (find a process whose Need ≤ Available, run it, release its resources):
- Work = (3,3,2). P1 Need (1,2,2) ≤ Work → run P1 → Work = (5,3,2).
- P3 Need (0,1,1) ≤ Work → run → Work = (7,4,3).
- P4 Need (4,3,1) ≤ Work → run → Work = (7,4,5).
- P0 Need (7,4,3) ≤ Work → run → Work = (7,5,5).
- P2 Need (6,0,0) ≤ Work → run → Work = (10,5,7).
A safe sequence ⟨P1, P3, P4, P0, P2⟩ exists, so the state is safe and requests can be granted along this path. If a request would leave no such sequence, the Banker's algorithm makes the requesting process wait, thereby avoiding deadlock.
Section B: Short Answer Questions
Attempt any EIGHT questions.
What is an operating system? List its main functions.
An operating system (OS) is system software that acts as an intermediary between the user/application programs and the computer hardware. It manages hardware resources and provides a convenient and efficient environment in which programs can run.
Main functions:
- Process management – creation, scheduling, synchronization and termination of processes.
- Memory management – allocation/deallocation of main memory, virtual memory.
- File management – creating, deleting, organizing files and directories, access control.
- Device (I/O) management – controlling peripheral devices via drivers and buffering.
- Storage/secondary-storage management – disk scheduling and allocation.
- Security and protection – authentication and controlling access to resources.
- Networking and communication – managing data exchange between systems.
- User interface – providing CLI or GUI for user interaction.
Differentiate between multiprogramming and multitasking.
| Aspect | Multiprogramming | Multitasking |
|---|---|---|
| Basic idea | Keeps several jobs in main memory at once so the CPU is never idle. | Allows a single user to run several tasks (processes) seemingly at the same time. |
| Goal | Maximize CPU utilization / throughput. | Maximize responsiveness / interactivity. |
| Switching trigger | CPU switches to another job when the current one waits for I/O. | CPU switches between tasks using time-sharing (time slices / quantum). |
| User interaction | Typically batch, little interaction. | Highly interactive (time-sharing system). |
| Relation | Multitasking is essentially a logical extension of multiprogramming with rapid time-based switching. | Built on top of multiprogramming. |
In short, multiprogramming switches on I/O waits to keep the CPU busy, while multitasking switches rapidly on time slices to give the illusion that many tasks run concurrently.
Explain the difference between a process and a program.
| Aspect | Program | Process |
|---|---|---|
| Nature | Passive entity. | Active entity. |
| Definition | A set of instructions stored on disk. | A program in execution. |
| Existence | Exists in secondary storage permanently. | Exists in main memory; has limited lifetime. |
| Resources | Does not hold any system resources. | Holds CPU, memory, registers, files, etc. |
| State/Counter | No program counter or state. | Has a program counter, registers, stack and a state (ready/running/waiting). |
| Instances | One program. | A single program can give rise to many processes. |
Summary: A program is just the code; a process is that code loaded into memory and running, together with its current activity and resources, represented by a PCB.
What is a system call? Explain its types.
System Call
A system call is a programmatic interface that allows a user-level program to request a service from the operating system kernel (e.g. file I/O, process creation). It is the controlled entry point through which a program switches from user mode to kernel mode.
Types of System Calls
- Process control –
fork(),exit(),wait(),exec(), load, abort: create, terminate and manage processes. - File management –
open(),read(),write(),close(),create(),delete(): operate on files. - Device management –
read(),write(),ioctl(), request/release device: access I/O devices. - Information maintenance –
getpid(),time(),getttimeofday(), set/get system data: obtain or set system and process attributes. - Communication –
pipe(),shmget(),send(),recv(): inter-process communication via message passing or shared memory. - Protection –
chmod(),umask(),chown(): control access permissions to resources.
Distinguish between starvation and deadlock.
| Aspect | Deadlock | Starvation |
|---|---|---|
| What happens | A set of processes are permanently blocked, each waiting for a resource held by another. | A process waits indefinitely because resources are repeatedly granted to other (often higher-priority) processes. |
| Progress | No process in the set makes progress. | Other processes do make progress; only the victim is denied. |
| Cause | The four Coffman conditions hold simultaneously (circular wait, etc.). | Biased resource allocation / scheduling policy (e.g. priority scheduling). |
| Resolution | Needs deadlock prevention, avoidance, detection & recovery. | Solved by aging (gradually raising the priority of waiting processes) or fair scheduling. |
| Also called | — | Indefinite blocking / lockout. |
Note: Every deadlock causes starvation for the involved processes, but starvation can occur without deadlock.
Explain context switching and its overhead.
Context Switching
Context switching is the mechanism by which the CPU saves the state (context) of the currently running process and loads the saved state of another process so that execution can be switched between processes. The context is held in each process's PCB and includes the program counter, CPU registers, and memory-management information.
Steps:
- Save the context of the current process P0 into its PCB.
- Update P0's state (e.g. ready or waiting) and move it to the proper queue.
- Select the next process P1 via the scheduler.
- Restore P1's context from its PCB and resume its execution.
When it occurs: on a timer interrupt (preemption), an I/O request/interrupt, a system call, or a higher-priority process becoming ready.
Overhead
Context switching is pure overhead – during the switch the CPU does no useful work. The cost includes:
- Time to save and restore registers and PCB data.
- TLB and cache flushing/refilling (the new process's working set is not yet cached).
- Possible memory-management updates (loading new page tables).
Frequent context switches (e.g. very small Round-Robin quantum) reduce effective CPU utilization, so the quantum/scheduling policy must balance responsiveness against switching overhead.
What is the producer-consumer problem? Explain in brief.
Producer–Consumer (Bounded-Buffer) Problem
The producer–consumer problem is a classic process-synchronization problem in which:
- A producer process generates data items and puts them into a shared, fixed-size buffer.
- A consumer process removes items from the buffer and uses them.
Requirements (synchronization constraints):
- The producer must not add an item when the buffer is full.
- The consumer must not remove an item when the buffer is empty.
- Access to the shared buffer must be mutually exclusive (only one process modifies it at a time) to avoid race conditions on the count/index.
Standard semaphore solution uses three semaphores:
semaphore mutex = 1; // mutual exclusion on buffer
semaphore empty = n; // count of empty slots
semaphore full = 0; // count of filled slots
Producer: Consumer:
wait(empty); wait(full);
wait(mutex); wait(mutex);
add item to buffer; remove item from buffer;
signal(mutex); signal(mutex);
signal(full); signal(empty);
Here empty blocks the producer on a full buffer, full blocks the consumer on an empty buffer, and mutex guarantees mutually exclusive access, preventing race conditions.
Explain the Dining Philosophers problem.
Dining Philosophers Problem
Five philosophers sit around a circular table; each alternates between thinking and eating. There are five chopsticks (forks), one between each pair of neighbours. To eat, a philosopher needs both the left and right chopsticks; after eating, both are released. It is a classic model of resource sharing among concurrent processes and illustrates deadlock and starvation.
Naïve solution (each chopstick = a semaphore):
semaphore chopstick[5] = {1,1,1,1,1};
Philosopher i:
wait(chopstick[i]); // pick up left
wait(chopstick[(i+1)%5]); // pick up right
eat;
signal(chopstick[i]);
signal(chopstick[(i+1)%5]);
think;
Problem: If all five philosophers simultaneously pick up their left chopstick, each waits forever for the right one → deadlock (circular wait), and a philosopher may also starve.
Solutions to avoid deadlock:
- Allow at most four philosophers at the table at a time.
- Pick up both chopsticks only if both are available (atomically).
- Asymmetric ordering: odd-numbered philosophers pick the left chopstick first, even-numbered pick the right first, breaking the circular-wait condition.
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 swapping pages in and out of memory than executing instructions. It happens when processes do not have enough frames to hold their working set, so each reference causes a page fault, replacing a page that is needed again immediately. The result is a sharp drop in CPU utilization even though the CPU appears busy handling page faults.
Cause: Too high a degree of multiprogramming → not enough frames per process → high page-fault rate → CPU utilization falls → the scheduler admits even more processes, worsening the situation.
Prevention / Control
- Working-set model – allocate each process enough frames to hold its current working set; suspend processes if total demand exceeds available frames.
- Page-Fault Frequency (PFF) control – monitor each process's fault rate; give it more frames if the rate is too high, take frames away if it is too low.
- Reduce degree of multiprogramming – swap out / suspend some processes so the rest have enough memory.
- Use local replacement so one thrashing process cannot steal frames from others.
- Add more physical RAM so working sets fit in memory.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Operating System (BSc CSIT, CSC259) question paper 2074?
- The full BSc CSIT (TU) Operating System (BSc CSIT, CSC259) 2074 (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) 2074 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) 2074 paper?
- The BSc CSIT (TU) Operating System (BSc CSIT, CSC259) 2074 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.