0% found this document useful (0 votes)
2 views

Process scheduling-module3

The document discusses process scheduling in operating systems, detailing its importance in managing CPU resources and ensuring efficient execution of multiple processes. It categorizes scheduling into non-preemptive and preemptive types, and outlines the roles of long-term, short-term, and medium-term schedulers. Additionally, it covers advantages and disadvantages of process scheduling, types of scheduling queues, context switching, and provides references for further reading.

Uploaded by

oseedigne0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Process scheduling-module3

The document discusses process scheduling in operating systems, detailing its importance in managing CPU resources and ensuring efficient execution of multiple processes. It categorizes scheduling into non-preemptive and preemptive types, and outlines the roles of long-term, short-term, and medium-term schedulers. Additionally, it covers advantages and disadvantages of process scheduling, types of scheduling queues, context switching, and provides references for further reading.

Uploaded by

oseedigne0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

METROPOLITAN INTERNATIONAL

UNIVERSITY

FACULTY : SCIENCE AND TECHNOLOGY.

LECTURER : JILL NATUKUNDA MARGRET.

COURSE UNIT : OPERATING SYSTEMS.

GROUP :2
AREA OF CONCENTRATION : Process Scheduling, Schedulers and Queues

GROUP MEMBERS

NO NAME REG NO. NO NAME REG NO.


1 TUGUME MARTIN 23C/BCS/074/UMC 16 BUSUULWA JOHN 23B/BCS/062/UMC
2 NANKABIRWA ELIZABETH K 24/BIT/062/UMC 17 AKELLO BRENDA 24/BIT/116/UMC
3 NAKALANZI ANNET 24/BIT/112/UMC 18 MUMBERE MARTIN 24/BAE/233/UMC
4 CHEBET NAOMI BATYA 23C/BCS/080/UMC 19 SSEKAMATTE HABIB 24/BIT/092/UMC
5 NAKAYAGA JALIAH 24/BIT/006/UMC 20 NAMANDA JAMINANT 24/BIT/094/UMC
MUZAMIRU
6 MBATUDDE JANAT 24/BIT/217/UMC 21 NABATANZI RAGIEBAH 23C/DIT/244/UMC
7 KAWUMA HABIBAH 24/BIT/059/UMC 22 NINSIIMA BONITA 24/BBC/004/UMC
8 NANFUKA TRISHA ALICE 24/BIT/181/UMC 23 NASSUUNA BETTY 24/BBC/001/UMC
9 WASSWA EMMANUEL 24/BIT/018/UMC 24 NANGOBI RACHEAL 24/BAE/122/UMC
10 MUTEGE SADIKI 23B/BCS/060/UMC 25 TUMUHEKYI EVAS 24/BIT/083/UMC
11 WAGALIMU KOSIMA 23B/BCS/058/UMC 26 KYOMUGISHA MARTHA 24/BIT/147/UMC
12 KIKONYOGO GEORGE KASULE 24/BIT/144/UMC 27 KAGOGWE FRANCIS 24/BIT/118/UMC
13 NANYONJO SANDRAH 24/BIT/057/UMC 28 MWESIGE AZALIA 24/BBC/002/UMC
14 NABIRYE LADHIYYAH 24/BIT/190/UMC 29 MUTEGEKI RAYMOND 24/BSE/021/UMC
15 OPIO DERRICK 23B/BCS/065/UMC 30 KAYESU LUTAAYA 24/BIT/126/UMC

Cover page
PROCESS SCHEDULING

The process scheduling is the activity of the process manager that handles the removal
of the running process from the CPU and the selection of another process on the basis of
a particular strategy.

Process scheduling is an essential part of a Multiprogramming operating systems. Such


operating systems allow more than one process to be loaded into the executable memory
at a time and the loaded process shares the CPU using time multiplexing.

Categories of Scheduling
Scheduling falls into one of two categories:
• Non-Preemptive: In this case, a process’s resource cannot be taken
before the process has finished running. When a running process finishes and
transitions to a waiting state, resources are switched. The switching of
resources occurs when the running process terminates and moves to a waiting
state.

2|Page
• Preemptive: In this case, the OS can switch a process from running state
to ready state. This switching happens because the CPU may give other
processes priority and substitute the currently active process for the higher
priority process.
Hint: Preemptive scheduling allows the operating system to interrupt a running process
to execute a higher priority process, while non-preemptive scheduling requires a process
to finish execution before another can start.

Process schedulers
Process schedulers are the essential parts of operating system that manage how the
CPU handles multiple tasks or processes. They ensure that processes are executed
efficiently, making the best use of CPU resources and maintaining system
responsiveness. By choosing the right process to run at the right time, schedulers help
optimize overall system performance, improve user experience, and ensure fair access
to CPU resources among competing processes. Their main task is to select the jobs to
be submitted into the system and to decide which process to run.
Types of process schedulers

Schedulers are of three types −

• Long-Term Scheduler
• Short-Term Scheduler
• Medium-Term Scheduler

Long Term Scheduler

It is also called a job scheduler. A long-term scheduler determines which programs are
admitted to the system for processing. It selects processes from the queue and loads
them into memory for execution. Process loads into the memory for CPU scheduling.

The primary objective of the job scheduler is to provide a balanced mix of jobs, such as
I/O bound and processor bound. It also controls the degree of multiprogramming. If the

3|Page
degree of multiprogramming is stable, then the average rate of process creation must be
equal to the average departure rate of processes leaving the system.

In some systems, the long-term scheduler might not even exist. For example, in time-
sharing systems like Microsoft Windows, there is usually no long-term scheduler.
Instead, every new process is directly added to memory for the short-term scheduler to
handle.
Slowest among the three (that is why called long term).

Short Term Scheduler

It is also called as CPU scheduler. Its main objective is to increase system performance
in accordance with the chosen set of criteria. It is the change of ready state to running
state of the process. CPU scheduler selects a process among the processes that are ready
to execute and allocates CPU to one of them.

Short-term schedulers, also known as dispatchers, make the decision of which process to
execute next. Short-term schedulers are faster than long-term schedulers.

Hint: The dispatcher is responsible for loading the process selected by the Short-term
scheduler on the CPU (Ready to Running State).
Structure

4|Page
Medium Term Scheduler

Medium-term scheduling is a part of swapping. It removes the processes from the


memory. It reduces the degree of multiprogramming. The medium-term scheduler is in-
charge of handling the swapped out-processes.

A running process may become suspended if it makes an I/O request. A suspended


process cannot make any progress towards completion. In this condition, to remove the
process from memory and make space for other processes, the suspended process is
moved to the secondary storage. This process is called swapping, and the process is
said to be swapped out or rolled out. Swapping may be necessary to improve the process
mix. When needed, it brings process back into memory and pick up right where it left
off. It is faster than long term and slower than short term.

Structure

5|Page
Advantages of process scheduling

• Efficient resource utilization

By selecting which processes run next, the operating system can optimize CPU usage
and prevent idle time.

NB; CPU optimization is the process of improving the efficiency of a computer's Central
Processing Unit (CPU) i.e. buffer size as this helps to lower the CPU usage etc. This
can help applications and systems run faster and use fewer resources.

• Improved responsiveness

Allows for quick switching between processes, giving the appearance of simultaneous
execution and providing better responsiveness for interactive tasks like typing or
clicking.

• Fairness

Scheduling algorithms can prioritize processes based on factors like arrival time or
priority, ensuring that all processes get a chance to execute.

NB; A scheduling algorithm in an operating system (OS) is a set of rules that determines
which process gets access to the CPU next, essentially deciding how much CPU time is
allocated to each process and when, aiming to optimize system performance by balancing
factors like wait time, turnaround time, and throughput. They decide which process from
the ready queue should be executed next based on specific criteria like arrival time,
priority, or estimated execution time.

• Multitasking capability

Enables multiple processes to run seemingly simultaneously, enhancing system


productivity.

• Flexibility
Different scheduling algorithms can be used depending on the workload, like
prioritizing short bursts for interactive tasks or longer processes for batch jobs.

6|Page
Disadvantages of process scheduling

• Context switching overhead

Switching between processes requires saving and restoring the state of each process,
which can consume CPU cycles and slow down system performance.

Note: In an operating system (OS), context switching refers to the process where
the CPU temporarily saves the state of a currently running process, allowing it to switch
to another process and execute its tasks, essentially enabling multitasking by giving
the appearance of multiple programs running simultaneously on a single CPU, it
involves storing the current process's state (like register values) and loading the state
of the new process to be executed, effectively pausing one process to resume another
later.

• Starvation potential

If a scheduling algorithm doesn't manage priorities well, a low priority process might
wait indefinitely for a high priority process to finish, leading to starvation.

• Complexity

Implementing and managing effective scheduling algorithms can be complex,


requiring careful consideration of different factors.

• Potential for long wait times

Depending on the chosen algorithm, some processes might experience long waiting
times if they are placed behind longer running processes.

• Algorithm selection challenge


Choosing the right scheduling algorithm for a specific workload can be difficult and
may require tuning based on system requirements.

7|Page
Process scheduling queue

A process scheduling queue is a data structure used by an operating system (OS) to


manage and organize processes as they move through different stages of execution.
These queues help the OS decide which process should execute next, ensuring efficient
CPU utilization and process management.

Types of Process Scheduling Queues

There are majorly three types of queues i.e.

• Job queue − This queue keeps all the processes in the system. For example, a
batch system where multiple jobs are waiting to be executed.
• Ready queue − This queue keeps a set of all processes residing in main memory,
ready and waiting to execute. A new process is always put in this queue. For
example, in multitasking system, processes that are not currently executing but
are ready to be scheduled.
• Device/blocked/waiting queue − The processes which are blocked due to
unavailability of an I/O device constitute this queue. For example, a process
waiting for user input or disk read/write operation.
Structure of queues

8|Page
Two-State Process Model

Two-state process model refers to running and non-running states which are described
below −

S.N. State & Description

Running
When a new process is created, it
1
enters into the system as in the
running state.

Not Running
Processes that are not running are
kept in queue, waiting for their turn
to execute. Each entry in the queue
is a pointer to a particular process.
Queue is implemented by using
linked list. Use of dispatcher is as
2 follows. When a process is
interrupted, that process is
transferred in the waiting queue. If
the process has completed or
aborted, the process is discarded. In
either case, the dispatcher then
selects a process from the queue to
execute.

9|Page
Context Switching

Using this technique, a context switcher enables multiple processes to share a single CPU.
Context switching is an essential part of a multitasking operating system features.

When the scheduler switches the CPU from executing one process to execute another,
the state from the current running process is stored into the process control block. After
this, the state for the process to run next is loaded from its own PCB and used to set the
PC, registers, etc. At that point, the second process can start executing.

Hint: PCB stands for Process Control Block, it refers to the dedicated data structure that
stores all essential information about the running process, including its current state,
program counter, register values, memory usage, memory allocation and I/O status.

Structure

10 | P a g e
Context switches are computationally intensive since register and memory state must be
saved and restored. To avoid the amount of context switching time, some hardware
systems employ two or more sets of processor registers. When the process is switched,
the following information is stored for later use.

• Program Counter
• Scheduling information
• Base and limit register value
• Currently used register
• Changed State
• I/O State information
• Accounting information

Note:

i. An I/O operation or input/output operation, is the process of reading or


writing data to or from the external sources. I/O operation, for example, when
you upload a file to a website, the server’s disk stores the files using I/O
operation, I/O operation, can involve peripheral devices such as printers,
keyboards, mice, scanners, monitors among others.
ii. I/O request, refers to a command or instruction that initiates a data transfer
between a computer system and peripheral devices such as hard drive, printer
etc. it serves as a communication interface between hardware components
and software, enabling exchange of information.

11 | P a g e
References

Silberschatz, Galvin, and Gagne (Operating System Concepts, 9th Edition, 2012):

https://www.geeksforgeeks.org/process-schedulers-in-operating-system/

https://www.tutorialspoint.com/operating_system/os_process_scheduling.htm

12 | P a g e

You might also like