[go: up one dir, main page]

0% found this document useful (0 votes)
3 views7 pages

Process

Process scheduling is a key operating system function that selects processes for CPU execution based on various algorithms to maximize efficiency and minimize wait times. There are different types of schedulers, including long-term, short-term, and medium-term, each serving distinct roles in managing process execution. Priority scheduling and round robin are two common algorithms, each with its advantages and disadvantages, impacting process management and resource allocation.

Uploaded by

Sana Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Process

Process scheduling is a key operating system function that selects processes for CPU execution based on various algorithms to maximize efficiency and minimize wait times. There are different types of schedulers, including long-term, short-term, and medium-term, each serving distinct roles in managing process execution. Priority scheduling and round robin are two common algorithms, each with its advantages and disadvantages, impacting process management and resource allocation.

Uploaded by

Sana Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Process Scheduling is a fundamental concept in operating systems that determines how

processes are selected for execution on the CPU. When multiple processes are in the
ready queue (i.e., they are waiting to run), the CPU scheduler selects one of them based
on a scheduling algorithm.

Objectives of Process Scheduling:

1. Maximize CPU utilization

2. Maximize throughput (number of processes completed per unit time)

3. Minimize turnaround time (total time from submission to completion)

4. Minimize waiting time (time a process waits in the ready queue)

5. Minimize response time (time from submission to the first response)

Types of Scheduling:

1. Preemptive Scheduling
The CPU can be taken away from a running process (e.g., Round Robin, SRTF).

2. Non-Preemptive Scheduling
Once a process starts, it runs till completion (e.g., FCFS, SJF).

Scheduler and Its Types

A scheduler in an operating system is a component that decides which process will run
next on the CPU. Since multiple processes can be ready to run at the same time, the
scheduler plays a crucial role in CPU resource management.

What is a Scheduler?

A scheduler is an OS module responsible for:

 Selecting a process from the ready queue

 Allocating the CPU to that process

 Managing context switching between processes


Types of Schedulers

There are three main types of schedulers in operating systems:

Speed
Scheduler Type Description Frequency
Requirement

1. Long-Term
Decides which jobs (processes) are
Scheduler (Job Infrequent Slow
admitted into the system for processing
Scheduler)

2. Short-Term
Selects which ready process gets the Very
Scheduler (CPU Very Fast
CPU next Frequent
Scheduler)

3. Medium-Term Swaps processes in and out of memory


Moderate Moderate
Scheduler (suspension/resumption)

1. Long-Term Scheduler

 Controls degree of multiprogramming (number of processes in memory)

 Selects a mix of I/O-bound and CPU-bound jobs to optimize performance

 May not exist in all systems (especially in modern time-sharing systems)

Example: In a batch processing system, it decides which batch jobs to start.

2. Short-Term Scheduler (CPU Scheduler)

 Most critical scheduler

 Selects processes from the ready queue and assigns the CPU

 Needs to be very fast because decisions are made frequently

Example: Choosing between processes in Round Robin or SJF.

3. Medium-Term Scheduler
 Used in swapping: temporarily removes (suspends) processes from main memory
and brings them back later

 Improves CPU and memory utilization

 Helps manage overloaded systems

Example: In a system with limited RAM, suspending a background process when


memory is low.

Priority Scheduling – Operating System

Priority Scheduling is a CPU scheduling algorithm in which each process is assigned a


priority, and the CPU is allocated to the process with the highest priority (usually the
lowest number = highest priority).

Key Features:

 Each process is given a priority number.

 CPU is assigned to the process with the highest priority.

 If two processes have the same priority, they are scheduled according to FCFS
(First-Come, First-Served).

 Can be:

o Preemptive: A new high-priority process preempts the current one.

o Non-preemptive: Once a process starts, it runs to completion.

Example: Non-Preemptive Priority Scheduling

Process Burst Time (ms) Priority

P1 10 3

P2 1 1

P3 2 4

P4 1 5
Process Burst Time (ms) Priority

P5 5 2

Execution Order:
P2 → P5 → P1 → P3 → P4
(Highest priority = 1)

Gantt Chart:

CopyEdit

| P2 | P5 | P1 | P3 | P4 |

0 1 6 16 18 19

Calculating Average Waiting Time:

Process Burst Time Priority Waiting Time

P2 1 1 0

P5 5 2 1

P1 10 3 6

P3 2 4 16

P4 1 5 18

Average Waiting Time = (0+1+6+16+18)/5 = 8.2 ms

Advantages:

 Flexible: Can prioritize important tasks (e.g., real-time processes).

 E icient for systems with varied task importance.

Disadvantages:
 Starvation: Low-priority processes may never get executed.

 Solution: Aging – gradually increase priority of waiting processes.

Round Robin (RR) Scheduling – Operating System

Round Robin (RR) is one of the simplest and most widely used CPU scheduling
algorithms, especially in time-sharing systems. It gives each process a fixed time slot
(quantum) in a cyclic order.

Key Concepts:

 Preemptive scheduling

 Each process gets the CPU for a time quantum (e.g., 4 ms)

 If a process does not finish within its quantum, it is preempted and placed at the
end of the ready queue

 Ensures fairness among all processes

Example:

Time Quantum = 4 ms

Process Burst Time

P1 10

P2 4

P3 5

Gantt Chart:

CopyEdit

| P1 | P2 | P3 | P1 | P3 | P1 |

0 4 8 12 16 17 21

Explanation:
 P1 runs for 4 → remaining 6

 P2 runs for 4 → finishes

 P3 runs for 4 → remaining 1

 P1 runs for 4 → remaining 2

 P3 runs for 1 → finishes

 P1 runs for 2 → finishes

Turnaround Time & Waiting Time

Process Burst Completion Turnaround (CT - AT) Waiting (TAT - BT)

P1 10 21 21 11

P2 4 8 8 4

P3 5 17 17 12

Average Turnaround Time = (21+8+17)/3 = 15.33 ms


Average Waiting Time = (11+4+12)/3 = 9 ms

Advantages:

 Fair: Every process gets an equal share of CPU

 No starvation

 Good response time in time-sharing systems

Disadvantages:

 High context switching overhead if time quantum is too small

 Poor average waiting time compared to SJF

Key Tip:
 Time Quantum must be carefully chosen:

o Too small → more context switches

o Too large → behaves like FCFS

You might also like