Unit 2 of 4 · BCA Sem 2

Unit 2: Process management and scheduling

Operating Systems notes · PTU syllabus (UGCC2508)

3 min read5 topics10 exam questions
On this page
  1. Unit summary
  2. Process and process states
  3. Process Control Block and schedulers
  4. Threads and multithreading
  5. Scheduling objectives and criteria
  6. FCFS, SJF and Round Robin
  7. Key terms
  8. Quick revision
  9. Important questions

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
CycleProcess state transitions
Process state transitions
1New
2Ready
3Running
4Waiting
5Terminated
  1. 1. New: Process is being created
  2. 2. Ready: Waiting for the CPU
  3. 3. Running: Executing on the CPU
  4. 4. Waiting: Waiting for I/O or an event
  5. 5. Terminated: Finished execution
1

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.

CycleProcess state diagram
Process state diagram
1New
2Ready
3Running
4Waiting
5Terminated
  1. 1. New: Being created
  2. 2. Ready: Waiting for the CPU
  3. 3. Running: Executing on the CPU
  4. 4. Waiting: Blocked for I/O or an event
  5. 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).

2

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.

SchedulerChoosesFrequency
Long-term (job)Which jobs enter memory (ready queue)Infrequent
Short-term (CPU)Which ready process runs nextVery frequent
Medium-termWhich processes to swap out and back inIn between
3

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.

4

Topic 4

Scheduling objectives and criteria

Key termsScheduling 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.

5

Topic 5

FCFS, SJF and Round Robin

ComparisonCPU scheduling algorithms
How it works
Key point

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

  1. Q1.Differentiate between a program and a process.
  2. Q2.What is a PCB? List its contents.
  3. Q3.What is a context switch?
  4. Q4.Differentiate between preemptive and non-preemptive scheduling.
  5. Q5.What is the convoy effect?
  6. Q6.Define turnaround time and waiting time.

Long-answer questions

  1. Q1.Explain the process state diagram with all transitions.
  2. Q2.Explain the types of schedulers and the PCB.
  3. Q3.Explain threads and multithreading models.
  4. 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.

WhatsApp us