0% found this document useful (0 votes)
5 views12 pages

Processor Management Cpu Scheduling

The document discusses processor management in modern computer systems, focusing on CPU allocation strategies managed by the operating system. It outlines various types of schedulers (long-term, medium-term, and short-term) and their roles in optimizing CPU usage, along with performance criteria and different scheduling algorithms such as FCFS, SJF, Round Robin, and Priority-based scheduling. The document emphasizes the importance of balancing resource use and ensuring fair access to CPU time for processes.

Uploaded by

akshitabhatt08
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)
5 views12 pages

Processor Management Cpu Scheduling

The document discusses processor management in modern computer systems, focusing on CPU allocation strategies managed by the operating system. It outlines various types of schedulers (long-term, medium-term, and short-term) and their roles in optimizing CPU usage, along with performance criteria and different scheduling algorithms such as FCFS, SJF, Round Robin, and Priority-based scheduling. The document emphasizes the importance of balancing resource use and ensuring fair access to CPU time for processes.

Uploaded by

akshitabhatt08
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/ 12

PROCESSOR MANAGEMENT

INTRODUCTION

In modern computer systems, several programs are allowed to reside in


computer's memory. Each program is supposed to be allocated CPU time
for its completion.

The CPU allocation strategy is the key area of processor management and is
handled by the Operating system.

PROCESSOR SCHEDULING

 Scheduling is a fundamental operating system function. All computer


resources are scheduled before use.

 Since CPU is one of the primary computer resources, its scheduling is


central to operating system design.

Scheduling refers to a set of policies and mechanisms supported by operating


system that controls the order in which the work to be done is completed. A
scheduler is an operating system program (module) that selects the next job to
be admitted for execution.

The main objective of scheduling are as follows:

1. Be Fair
2. Maximise Throughput
3. Maximise Number of Interactive Users
4. Minimise Overheads
5. Be Predictive
6. Balance Resource Use
7. Avoid Indefinite Postponement
8. Enforce Priority
9. Give Preferences to processes holding Key resources
10. Give better service to process exhibiting desirable behavior
11. Degrade gracefully under heavy loads
Process & Schedulers :

Types of Schedulers

Three types of schedulers in terms objectives, operating environment and


relationship to other schedulers:

1. Long Term Scheduler (Less Frequently)


2. Medium Term Scheduler (Frequently)
3. Short Term Scheduler (Very Frequently)
1. Long term scheduler :

a) Sometimes it is also called job scheduling. This determines which


job shall be admitted for immediate processing.

b) There are always more processes than it can be executed by CPU


operating System. These processes are kept in large storage devices
like disk for later processing. The long term scheduler selects
processes from this pool and loads them into memory.

c) The short term scheduler (also called the CPU scheduler) selects
from among the processes in memory which are ready to execute
and assigns the CPU to one of them.

d) The long term scheduler executes less frequently.

e) If the average rate of number of processes arriving in memory is


equal to that of departing the system then the long- term scheduler
may need to be invoked only when a process departs the system.
Because of longer time taken by CPU during execution, the long
term scheduler can afford to take more time to decide which
process should be selected for execution.

f) It may also be very important that long term scheduler should take a
careful selection of processes i.e. processes should be combination
of CPU and I/O bound types.

Generally, most processes can be put into any of two categories: CPU
bound or I/O bound

 If all processes are I/O bound, the ready queue will always be empty and the
short term scheduler will have nothing to do.

 If all processes are CPU bound. no process will be waiting for I/O operation
and again the system will be unbalanced. Therefore, the long term scheduler
provides good performance by selecting combination of CPU bound and I/O
bound process.
2. Medium term scheduler:

a) Most of the processes require some I/O operation. In that case, it may
become suspended for I/O operation after running a while.
b) It is beneficial to remove these process (suspended) from main memory to
hard disk to make room for other processes.
c) At some later time these process can be reloaded into memory and continued
where from it was left earlier. This is said to be Context Switching. The
process is swapped in and swap out by the medium term scheduler.
(Context Switching)
d) The medium term scheduler has nothing to do with the suspended processes.
But the moment the suspending condition is fulfilled, the medium term
scheduler get activated to allocate the memory and swap in the process and
make it ready for commenting CPU resources.
e) In order to work properly, the medium term scheduler must be provided with
information about the memory requirement of swapped out processes which
is usually recorded at the time of swapping and stored in the related process
control block.
f) In term of the process state transition diagram the medium term scheduler
controls suspended to ready transition of swapped processes.

3. The short term scheduler:

a) It allocates processes belonging to ready queue to CPU for immediate


processing.
b) Its main objective is to maximize CPU requirement.
c) Compared to the other two scheduler it is more frequent.
d) It must select a new process for execution quite often because a CPU
executes a process only for few millisecond before it goes for I/O operation.
e) Often the short term scheduler executes at least once very 10 millisecond. If
it takes 1 millisecond to decide to execute a process for 10 millisecond, the
1/(10+1) = 9% of the CPU is being wasted simply for scheduling the work.
Therefore. it must be very fast.
f) In terms of the process state transition diagram it is in charge of ready to
running state transition
Scheduling and Performance Criteria

Some performance criteria that are frequently used optimizing goal are:

1. CPU Utilisation
2. Throughput
3. Turnaround Time
4. Waiting Time
5. Response Time

CPU Utilisation:

 How mush time the CPU is utilised/Busy.


 CPU must not be idle.
 The key idea is that if the CPU is busy all the time, the utilisation
factor of all the components of the system will be also high.
Throughput:

 It refers to the amount of work completed in a unit of time (Number of


outputs per unit time).
 One simplest way to measure throughput is by means of the number
of processes that are completed in a unit of time.
 The higher the number of processes, the more work apparently being
done by the system.

Turnaround Time:

 It is the time interval, from the time of submission of a job to the time
of its completion.
 It may be the sum of the periods spent waiting to get into memory,
waiting in the ready queue, CPU time and I/O operations etc.

Waiting Time:

 In multiprogramming operating system several jobs reside at a


time in memory. CPU executes only one job at a time. The rest of
jobs wait for the CPU.
 The waiting time is the time a job has to wait in the ready queue to
get the job completed.

 Waiting Time may be = TAT-Actual CPU time

Response time:

 The Response time is the time a job has to wait in the ready queue
to get the CPU for the first time. (first response)

 It is most frequently considered in time sharing and real time


operating system.
Processor (CPU) Scheduling Algorithms

 CPU scheduling deals with the problem of deciding which of the


processes in the ready queue to be allocated the CPU.

 A major division among scheduling algorithms is that whether they


support pre-emptive or non-preemptive scheduling discipline.

 A scheduling discipline is non-preemptive if once a process has


been given the CPU, the CPU cannot be taken away from that
process. A scheduling discipline is pre-emptive if the CPU can be
taken away.

Queuing System Model:

 Arrivals are independent Random events (follow Poisson distribution).


Number of arrivals during a given interval time depends only on the length
of interval and not on the history.
Scheduling Algorithms

1. First-Come-First-Served (FCFS) Scheduling

 Its implementation is straightforward which is maintained by FIFO


(First-in-First-out) queue.

 Once a process has the CPU, it runs to completion.

Consider the following example :

Process Execution/Burst time


P1 24
P2 3
P3 3
If processes P1, P2 and P3 arrive in order P1,P2 and P3.

The Turn Around Times (TATs) are :

P1 P2 P3
0 24 27 30

The TAT for P1 : 24


The TAT for P2 : 27
The T AT for P3 : 30
Average TAT : (24+27+30)/3 = 27

2. Shortest-job-First (SJF)-Scheduling

 A different approach to CPU scheduling is the shortest-job-First where


the scheduling of a job or a process is done on the basis of its having
shortest execution time.
 If two processes have the same CPU time, FCFS is used.
As an example consider the following set of processes units of time.
Process CPU time
P1 5
P2 10
P3 8
P4 3
Using Shortest job first scheduling, these processes would be scheduled in
the P4-P1 -P3-P2 order.

Waiting time is
0 + 3 + 8 + 16 / 4 = 27/4 = 6.75 units of time.
If we were using the FCFS scheduling then the average waiting time will be
= (0 + 5 + 15 + 23)/4 = 43/4 = 10.75 units of time.
Shortest job first (SJF) may be implemented in either non- preemptive or
preemptive varieties (SJN, SRT).
In either case, whenever the SJF scheduler is invoked, it searches the ready
queue to find the job or the process with the shortest execution time. The
difference between the two (preemptive or non-Preemptive) SJF scheduler
lies in the condition that lead to invocation of the scheduler and
consequently the frequency of its execution.

3.Round Robin Scheduling:

 This is one of the oldest, simplest and widely used algorithm.


 The round robin scheduling algorithm is primarily used in a time-sharing
and a multi-user system where the primary requirement is to provide
reasonably good response times and in general to share the system fairly
among all system users.
 Basically the CPU time is divided into time slices.
 Each process is allocated a small time-slice quantum (from 10-100
millisecond) while it is running.
 No process can run for more than one time slice when there are others
waiting in the ready queue. If a process needs more CPU time to
complete after exhausting one time slice, it goes to the end of ready
queue to await the next allocation.

Example: If there are 3 processes: P1, P2 and P3 which require the following
CPU time

Process Burst time/Execution time


P1 25
P2 5
P3 5
Thus the resulting round robin schedule is:

P1 P2 P3 P1 P1 P1 P1
0 5 10 15 20 25 30 35
Context switching is the key consideration.

Round-robin scheduling is often regarded as a fair scheduling discipline. It is


also one of the best known scheduling disciplines for achieving good and
relatively evenly distributed response time.

4. Priority based Scheduling:

 A priority is associated with each process and the scheduler always picks up
the highest priority process for execution from the ready queue.

 Equal priority processes are scheduled FCFS. The level of priority may be
determined on the basis of resource requirements, processes characteristics
and its run time behaviour.

Highest Response Ratio Next (HRN):

 Brinch Hansen developed HRN strategy that corrects some of the


weaknesses of SJF, SJN etc., such as excessive favouratism toward short
new jobs

 It is a Non-preemptive scheduling in which the priority of each job is a


function not only of the Service Time but also of the amount of time the
job has been waiting for service.

Dynamic Priority in HRN

Priority = (Time Waiting + Service Time) / Service Time

 Once a job gets CPU it runs to completion


Multiple-level-Queue (MLQ) scheduling :

processes are classified into different groups.

interactive processes (foreground) and


batch processes (background)

could be considered as two types of processes because of their different


response time requirements, scheduling needs and priorities.

A multi queue scheduling algorithm partitions the ready queue into separate
queues. Processes are permanently assigned to each queue, usually based upon
properties such as memory size or process type. Each queue has its own
scheduling algorithm. The interactive queue might be scheduling by a round-
robin algorithm while batch queue follows FCFS.
As an example of multiple queues scheduling one simple approach to
partitioning of the ready queue into system processes, interactive processes and
batch processes which creates a three ready queues

Figure 7: Multiple queue Scheduling


Each queue is serviced by some scheduling discipline best suited to the type of
processes stored in the queue. There are different possibilities to manage
queues. One possibility is to assign a time slice to each queue, which it can
schedule among different processes in its queue. Foreground processes can be
assigned 80% of CPU whereas background processes are given 20% of the
CPU time.
The second possibility is to execute the high priority queue first. No process in
the batch queue, for example could run unless the queue for system processes
and interactive processes were all empty. If an interactive process entered the
ready queue while a batch process is running, the batch process would be pre-
empted.

You might also like