RGPV Notes Hub
IT501 Operating System - Unit 2

CPU Scheduling, Processes, Threads & Synchronization

This unit explains how an Operating System selects processes for CPU execution, manages process operations, supports threads, enables communication between processes, and controls shared resources using critical section rules and semaphores.

What you will learn

  • How CPU scheduling works
  • How processes and threads are managed
  • How IPC allows process communication
  • How semaphores solve synchronization issues

Unit 2 Syllabus Coverage

All topics are arranged according to the RGPV IT501 Operating System Unit 2 syllabus.

Basic Concepts of CPU Scheduling
Scheduling Criteria
Scheduling Algorithms
Algorithm Evaluation
Multiple Processor Scheduling
Process Concept
Operations on Processes
Threads
Inter Process Communication
Precedence Graphs
Critical Section Problem
Semaphores
Classical Synchronization Problems

1. Basic Concepts of CPU Scheduling

CPU scheduling is used when many processes are ready for execution but CPU can execute only one process at a time. The operating system selects one process from the ready queue and gives CPU to it.

Easy meaning: CPU scheduling decides β€œwhich process will run next?”

2. Scheduling Criteria

Scheduling criteria are used to judge whether a scheduling algorithm is good or not.

Criteria Meaning Goal
CPU Utilization How much CPU remains busy Maximum
Throughput Number of processes completed per unit time Maximum
Waiting Time Time spent in ready queue Minimum
Turnaround Time Total time from submission to completion Minimum
Response Time Time taken to give first response Minimum

3. Scheduling Algorithms

Scheduling algorithms define the rule used by the OS to select a process for CPU execution.

Algorithm Basic Idea Type
FCFS First arriving process gets CPU first. Non-preemptive
SJF Process with shortest CPU burst gets priority. Both
Priority Scheduling CPU is given according to priority value. Both
Round Robin Each process gets fixed time quantum. Preemptive

4. Algorithm Evaluation

Algorithm evaluation means comparing scheduling algorithms using waiting time, turnaround time, response time, throughput and CPU utilization.

In exams, students are often asked to calculate average waiting time and average turnaround time for FCFS, SJF or Round Robin scheduling.

5. Multiple Processor Scheduling

Multiple processor scheduling is used when a system has more than one CPU. The main challenge is to divide processes among processors fairly and efficiently.

  • Asymmetric Multiprocessing: One processor controls scheduling decisions.
  • Symmetric Multiprocessing: Each processor schedules independently.
  • Load Balancing: Workload is distributed among processors.

6. Process Concept

A process is a program under execution. It contains program code, program counter, registers, stack, data section and process control block.

Process State Flow

New
Ready
Running
Waiting
Terminated

7. Operations on Processes

The operating system performs many operations on processes during execution.

  • Process Creation: A new process is created by the OS.
  • Process Scheduling: Ready process is selected for CPU.
  • Process Execution: Process instructions are executed.
  • Process Waiting: Process waits for I/O or event.
  • Process Termination: Process finishes or is stopped.

8. Threads

A thread is a lightweight unit of execution inside a process. One process can contain multiple threads, and these threads share the same process resources.

  • Threads improve responsiveness.
  • Threads reduce context switching cost.
  • Threads are useful in browsers, editors and servers.

9. Inter Process Communication

Inter Process Communication allows different processes to exchange data and coordinate with each other.

IPC Method Meaning
Shared Memory Processes communicate through common memory area.
Message Passing Processes communicate by sending and receiving messages.

10. Precedence Graphs

A precedence graph shows the order in which processes or tasks must be executed. It is useful when one task depends on the completion of another task.

Example: If Task B depends on Task A, then A must execute before B.

11. Critical Section Problem

Critical section is the part of a program where shared data or shared resources are accessed. The problem is to ensure that only one process enters the critical section at one time.

  • Mutual Exclusion: Only one process can enter critical section.
  • Progress: Selection of next process should not be delayed.
  • Bounded Waiting: No process should wait forever.

12. Semaphores

Semaphore is a synchronization variable used to control access to shared resources. It is mainly used to solve critical section and synchronization problems.

Semaphore Type Description
Binary Semaphore Value can be 0 or 1. It works like a lock.
Counting Semaphore Value can be more than 1. It controls multiple resources.

13. Classical Problems of Synchronization

Classical synchronization problems are standard problems used to understand process synchronization.

  • Producer-Consumer Problem: Manages producer and consumer access to a shared buffer.
  • Readers-Writers Problem: Allows multiple readers but controls writers carefully.
  • Dining Philosophers Problem: Explains resource sharing, waiting and deadlock possibility.

Important Exam Questions

IT501 Operating System Unit 2 PYQ Analysis

Unit 2 is mostly asked through CPU scheduling numericals and synchronization-based theory questions.

Most Expected Area

CPU Scheduling Algorithms

β˜…β˜…β˜…β˜…β˜…

Repeated Numerical

FCFS, SJF and Round Robin scheduling calculations.

95% Probability

Important Theory

Critical Section, Semaphores and Synchronization.

90% Probability
Topic Question Style Importance
CPU Scheduling Numerical / Theory β˜…β˜…β˜…β˜…β˜…
Process Concept Diagram / Explanation β˜…β˜…β˜…β˜…β˜†
Threads Short Note β˜…β˜…β˜…β˜†β˜†
Critical Section Long Answer β˜…β˜…β˜…β˜…β˜…
Semaphores Long Answer / Problem β˜…β˜…β˜…β˜…β˜…
← Previous Unit Back to OS Next Unit β†’