2 Process Management

Operating Systems · Unit 2 · 10 hrs

Process Management

Exam-focused notes for Process Management (Operating Systems, CSC264): what the TU syllabus asks and how it has actually been tested, with 19 solved past questions from this unit.

What this unit covers

  • Process vs Program
  • Multiprogramming
  • Process Model
  • Process States
  • Process Control Block
  • Threads
  • Thread vs Process
  • User and Kernel Space Threads
  • Inter Process Communication
  • Race Condition
  • Critical Section
  • Implementing Mutual Exclusion: Mutual Exclusion with Busy Waiting (Disabling Interrupts, Lock Variables, Strict Alteration, Peterson's Solution, Test and Set Lock)
  • Sleep and Wakeup
  • Semaphore
  • Monitors
  • Message Passing
  • Classical IPC problems: Producer Consumer, Sleeping Barber, Dining Philosopher Problem
  • Process Scheduling: Goals, Batch System Scheduling (First-Come First-Served, Shortest Job First, Shortest Remaining Time Next), Interactive System Scheduling (Round-Robin Scheduling, Priority Scheduling, Multiple Queues), Overview of Real Time System Scheduling

Classical IPC problems

208110 marks

Explain the Sleeping Barber problem. Illustrate on how it can be solved.[10]

The Sleeping Barber Problem is a classic Inter-Process Communication (IPC) and process synchronization problem introduced by Dijkstra. It models a real-world scenario involving a barber shop and illustrates the challenges of coordinating multiple concurrent...

Full solved answer →

Semaphore

20815 marks

Explain how semaphore solves the problem of critical section. [5]

A critical section is the part of a program where shared memory or shared resources are accessed. When multiple processes/threads enter their critical sections simultaneously, a race condition occurs, producing incorrect or unpredictable results depending o...

Full solved answer →

Process Scheduling

20815 marks

Calculate the average waiting time and turnaround time using priority algorithm (Priority 1 being the highest) for the given scenario:

$$\begin{array}{|c|c|c|c|} \hline \text{PID} & \text{Burst Time} & \text{Arrival Time} & \text{Priority} \ \hline A & 3 & 0 & 3 \ B & 2 & 2 & 3 \ C & 4 & 3 & 2 \ D & 2 & 3 & 1 \ \hline \end{array}$$

[5]

PID Burst Time Arrival Time Priority ---------------------------------------- A 3 0 3 B 2 2 3 C 4 3 2 D 2 3 1 Priority 1 = highest. Assume non-preemptive priority scheduling. --- - t = 0: Only A available → A runs 0 to 3. - t = 3: Ready = B (P3), C (P2), D ...

Full solved answer →
208010 marks

(question text pending review) # Answer

When does the request switch from user mode to kernel mode?

A request switches from user mode to kernel mode through a system call (also calle

Process Arrival Time (AT) Burst Time (BT) Priority ------------ P0 0 5 1 (Lowest) P1 1 3 4 (Highest) P2 2 8 2 P3 3 6 3 Priority convention (from question): higher number = higher priority (P1 = 4 = Highest). --- A CPU runs in two modes controlled by a mode ...

Full solved answer →
20795 marks

For the following dataset, compute average waiting time for SRTN and SJF.

ProcessArrival TimeBurst Time
P007
P124
P241
P354

[5]

Process Arrival Time Burst Time ---------------------------------- P0 0 7 P1 2 4 P2 4 1 P3 5 4 All required data present. --- At each new arrival, compare remaining times and run the smallest. - t=0: Only P0. Run P0. - t=2: P1 arrives (4). P0 remaining = 5....

Full solved answer →
20785 marks

Discuss the concept of SJF and SRTN scheduling algorithms with suitable example. [5]

SJF is a non-preemptive CPU scheduling algorithm in which the process with the smallest burst time (CPU time) is selected next for execution from the ready queue. Once a process starts executing, it runs to completion without interruption. - Non-preemptive ...

Full solved answer →
207610 marks

Interactive System Goals and Scheduling Algorithms

Interactive systems serve users who expect fast, predictable responses. Scheduling goals: - Response Time: Minimize time from request to first response. - Proportionality: Simple tasks should feel quick; user expectations must be met. - Fairness: Every proc...

Full solved answer →
2080.110 marks

Why do we need to schedule process? Find the average waiting time and average turnaround time for the following set of processes using FCFS, SJF, RR (Quantum = 3) and shortest remaining time next.

ProcessCPU burst timeArrival time
P1200
P22515
P31030
P41545

[10]

Process Burst Time Arrival Time ---------------------------------- P1 20 0 P2 25 15 P3 10 30 P4 15 45 Quantum for RR = 3 Formulas: - $TAT = CT - AT$ - $WT = TAT - BT$ --- - CPU utilization: keep the CPU busy in a multiprogramming environment. - Throughput: ...

Full solved answer →

Critical Section

208010 marks

How do you recognize critical section? Why do we need to synchronise it? Consider the request for the page references 7,0,1,2,0,3,0,4,2,3,0,3,2. Find the number of page fault for FIFO and LRU with 4 page frames.[10]

--- A critical section is the segment of code in a process where it accesses and manipulates shared resources (shared variables, memory, files, buffers, etc.) that must not be accessed by more than one process simultaneously. How to recognize it: - It reads...

Full solved answer →

Implementing Mutual Exclusion

20805 marks

How can we achieve mutual exclusion? Describe. [5]

Mutual exclusion ensures that when one process is executing in its critical region (accessing shared memory/resources), no other process is allowed to enter its critical region at the same time. --- - On a single-processor system, each process disables all ...

Full solved answer →
20795 marks

List any two demerits of disabling interrupt to achieve mutual exclusion. Describe about fixed and variable partitioning. [5]

According to the notes, the following are two demerits of disabling interrupts to achieve mutual exclusion: 1. Unsafe to give power to user processes: It is unwise to give user processes the power to turn off interrupts. If a user process disables interrupt...

Full solved answer →
20785 marks

What is lock variable? Discuss its working and problems associated with it in detail. [5]

A lock variable is a single, shared variable used to implement mutual exclusion among competing processes. It is initially set to 0 and acts as a flag to indicate whether any process is currently inside its critical region. - Lock = 0 → No process is in the...

Full solved answer →
2080.15 marks

How lock variable is used in achieving mutual exclusion? Describe. [5]

A lock variable is a shared variable used to control access to a critical region. It is one of the software-based approaches to achieving mutual exclusion with busy waiting. --- A single shared variable called the lock is maintained, initially set to 0. Loc...

Full solved answer →

Thread vs Process

20805 marks

What makes thread different with process? Draw the transition diagram between states of a process. [5]

Based on the curriculum notes, the key differences are: Process Thread ------ Process is heavy weight or resource intensive. Thread is light weight, taking lesser resources than a process. Process switching needs interaction with the operating system. Threa...

Full solved answer →

Race Condition

207910 marks

When does race condition occur in inter process communication? What does busy waiting mean and how it can be handled using sleep and wakeup strategy?[10]

A race condition is a situation that may occur inside a critical section. This happens when the result of multiple thread/process execution in a critical section differs according to the order in which the threads execute. Race conditions occur in IPC when ...

Full solved answer →

Sleep and Wakeup

207810 marks

What kind of problem arises with sleep and wakeup mechanism of achieving mutual exclusion? Explain with suitable code snippet.[10]

Sleep and Wakeup is an inter-process communication mechanism used to achieve mutual exclusion and process synchronization. As stated in the notes: "Sleep is a system call that causes the caller to block (i.e., to be suspended) until another process wakes it...

Full solved answer →

User and Kernel Space Threads

20765 marks

When threads are better than processes? Explain the concept of user level threads in detail. [5]

--- Threads are preferred over processes in the following situations: Situation Reason ------ Resource sharing All threads share the same set of open files, child processes, and memory. Processes require separate resources. Speed and lightweight operation T...

Full solved answer →

Monitors

20765 marks

What is problem associated with semaphores? Explain the concept of monitors in brief. [5]

Semaphores are a widely used synchronization mechanism, but they suffer from several serious problems: 1. Incorrect Use / Programming Errors: Semaphores require programmers to call wait() (down) and signal() (up) in the correct order. A single mistake can c...

Full solved answer →

Process States

2080.15 marks

What is system call? Describe the transition between different states of process. [5]

--- A system call is the interface between a process (i.e., a user program) and the operating system. When a user program needs to request a service from the operating system (such as reading a file, creating a process, etc.), it does so through system call...

Full solved answer →