Unit 2: Process management and scheduling
Operating Systems notes · PTU syllabus (UGCC2508)
On this page
Unit summary
A process is a program in execution. The OS must create processes, keep track of them and decide which one gets the CPU next. This unit covers process states, the process control block, threads, scheduling criteria and the CPU scheduling algorithms FCFS, SJF and Round Robin.
After this unit you can
- Draw the process state diagram and explain each transition
- Describe the PCB and the role of schedulers
- Explain threads and multithreading models
- Solve FCFS, SJF and Round Robin problems and compare their performance
PTU syllabus topics
- Process definition
- states and state transitions
- process scheduling
- PCB
- threads and multithreading
- scheduling objectives and algorithms
- preemptive/non-preemptive CPU scheduling (FCFS, SJF, Round Robin)
- performance evaluation of scheduling algorithms
- 1. New: Process is being created
- 2. Ready: Waiting for the CPU
- 3. Running: Executing on the CPU
- 4. Waiting: Waiting for I/O or an event
- 5. Terminated: Finished execution
Topic 1
Process and process states
A process is a program in execution, with its own code, data, stack and CPU state. A program is passive (a file); a process is active.
- 1. New: Being created
- 2. Ready: Waiting for the CPU
- 3. Running: Executing on the CPU
- 4. Waiting: Blocked for I/O or an event
- 5. Terminated: Finished
Transitions: admit (new → ready), dispatch (ready → running), interrupt/time-out (running → ready), I/O wait (running → waiting), I/O completion (waiting → ready), exit (running → terminated).
Topic 2
Process Control Block and schedulers
The Process Control Block (PCB) is the data structure in which the OS stores everything about a process: process ID, state, program counter, CPU registers, scheduling information (priority), memory information, accounting information and I/O status. Context switch: saving the PCB of the running process and loading the PCB of the next one. It is pure overhead.
| Scheduler | Chooses | Frequency |
|---|---|---|
| Long-term (job) | Which jobs enter memory (ready queue) | Infrequent |
| Short-term (CPU) | Which ready process runs next | Very frequent |
| Medium-term | Which processes to swap out and back in | In between |
Topic 3
Threads and multithreading
A thread is a lightweight unit of execution within a process. Threads of the same process share code, data and files but have their own stack and registers.
- Benefits: responsiveness, resource sharing, economy (cheaper than processes) and use of multiple cores.
- Multithreading models: many-to-one, one-to-one and many-to-many (mapping user threads to kernel threads).
Example
A web browser uses one thread to download a page and another to keep the window responsive.
Topic 4
Scheduling objectives and criteria
- CPU utilisation
- Keep the CPU as busy as possible (maximise)
- Throughput
- Processes completed per unit time (maximise)
- Turnaround time
- Completion time − arrival time (minimise)
- Waiting time
- Turnaround time − burst time (minimise)
- Response time
- Time from submission to first response (minimise)
Preemptive scheduling can take the CPU away from a running process; non-preemptive lets it run until it finishes or blocks.
Topic 5
FCFS, SJF and Round Robin
FCFS
First come, first served; non-preemptive
Simple; convoy effect behind long jobs
SJF
Shortest burst first; preemptive version is SRTF
Minimum average waiting time; may starve long jobs
Round Robin
Each process gets a time quantum in turn; preemptive
Fair and good for time-sharing; quantum size matters
Example
Processes P1 = 24, P2 = 3, P3 = 3 ms, all arriving at 0. FCFS (P1, P2, P3): waiting times 0, 24, 27 → average 17 ms. SJF (P2, P3, P1): waiting times 6, 0, 3 → average 3 ms.
Example
Round Robin with quantum 4 for the same jobs: P1 runs 0–4, P2 4–7, P3 7–10, then P1 10–30. Waiting: P1 = 6, P2 = 4, P3 = 7 → average 5.67 ms.
Exam tip
Always draw a Gantt chart first, then compute completion, turnaround and waiting times in a table. Examiners give marks for each step.
Key terms
- Process
- A program in execution
- PCB
- The data structure holding all information about a process
- Context switch
- Saving one process's state and loading another's
- Thread
- A lightweight unit of execution within a process
- Time quantum
- The fixed CPU time slice in Round Robin
Quick revision
- States: new, ready, running, waiting, terminated.
- Turnaround = completion − arrival; waiting = turnaround − burst.
- SJF gives the minimum average waiting time.
- RR is preemptive; too large a quantum becomes FCFS, too small causes too many switches.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Differentiate between a program and a process.
- Q2.What is a PCB? List its contents.
- Q3.What is a context switch?
- Q4.Differentiate between preemptive and non-preemptive scheduling.
- Q5.What is the convoy effect?
- Q6.Define turnaround time and waiting time.
Long-answer questions
- Q1.Explain the process state diagram with all transitions.
- Q2.Explain the types of schedulers and the PCB.
- Q3.Explain threads and multithreading models.
- Q4.Solve a scheduling problem using FCFS, SJF and Round Robin and compare their average waiting times.
Stuck on this unit?
Message SBS on WhatsApp for help with Operating Systems, or to ask about studying BCA at Synetic.
