You are on page 1of 3

Operating Systems Unit 04

4.1 Pre-emptive Scheduling

Scheduling Preemptive scheduling is a multitasking


strategy that allows tasks to be preempted.
Scheduling is to dispatch processes in main
Preemption is the act of interrupting a task that
memory to CPU processing using scheduling
is currently running on the CPU. The
criteria.
interrupted task is usually resumed at a later
Objectives of Scheduling time.

1. Fairness Non-Pre-emptive Scheduling


2. Throughput Maximization
Non-preemptive scheduling is a type of
3. Predictability
scheduling algorithm where a process runs
4. Scheduling Overhead Minimization
until it finishes or goes to the wait state. In this
5. Graceful Degradation Under Heavy
scheduling, once the resources (CPU cycles) are
Load Conditions
allocated to a process, the process holds the
6. Pre-emptability
CPU until it gets terminated or reaches a
CPU Burst & I/O Burst cycles waiting state.

Scheduling Criteria

4.2

Scheduling algorithms

FCFS

Processes selected in the order in which they


entered the ready queue.

CPU burst and I/O burst are two states of Not pre-emptive.
process execution
Process which voluntarily relinquishes control
CPU burst: The amount of time a process uses of CPU is added to end of ready queue.
the CPU to execute code. This is the running
Turnaround times cannot be guaranteed, so
state of the process.
not good for interactive environments.
I/O burst: The amount of time a process waits
Resource utilisation can be poor and unevenly
for input-output before needing CPU time. This
distributed.
is the waiting state of the process.
SJF

Selects shortest job in the ready queue.


Operating Systems Unit 04

Non-preemptive. Round-Robin favours processes which


complete within their time-slice.
OS needs to know estimated execution times of
processes. Quantum size is important, because too large a
quantum will means that processes can
Unfair on long jobs.
complete, but all other processes will have long
SRTN to wait.

Modification of SJN to allow preemption by If there are too many ready processes, then
shorter jobs entering the ready queue. quantum size could be too small for any
process to do a significant amount of work
Long jobs have to wait even longer. before it is interrupted (sudden load
SRTN has to calculate how much Ɵme is degradation).
needed to complete the current job, and then Multilevel Queue
decide whether to switch processes if the new
process is only a bit shorter than the current Multilevel queue scheduling is a type of CPU
one. scheduling in which the processes in the ready
state are divided into different groups, each
SRTN (and SJN) try to maximise throughput. group having its own scheduling needs. The
ready queue is divided into different queues
Priority Based Scheduling according to different properties of the
process like memory size, process priority, or
Priority scheduling is a process scheduling process type. All the different processes can
algorithm that assigns priority to each process. be implemented in different ways, i.e., each
The scheduler selects tasks to work on based process queue can have a different scheduling
on their priority. algorithm.

Processes with higher priority are executed


first, followed by processes with lower priority.

Processes with equal priorities are executed


on a first-come-first-served (FCFS) or round
robin basis.

Round Robin

Tyipcally used in time-sharing or interactive


environments, where good terminal response
time is important. 4.3

Each runnable process in the system is given an Deadlock


equal time-slice (quantum) of the CPU's time. System Models
When quantum expires, process is interrupted. 1. For the purposes of deadlock
Queue ordered according to order in which discussion, a system can be modeled
processes were created. as a collection of limited resources that
can be divided into different categories
A Hardware Clock is used to generate and allocated to a variety of processes,
interrupts. Quantum size changes dynamically. each with different requirements.
2. Memory, printers, CPUs, open files,
tape drives, CD-ROMs, and other
Operating Systems Unit 04

resources are examples of resource the tape drive and printer,


categories. are inherently non-
3. By definition, all resources within a shareable.
category are equivalent, and any of the b. There are two techniques
resources within that category can to detect the deadlock by
equally satisfy a request from that simulation which are
category. If this is not the case (i.e. if i. Resource
there is some difference between the allocation graph
resources within a category), then that ii. Banker’s
category must be subdivided further. algorithm
For example, the term “printers” may
need to be subdivided into “laser
printers” and “color inkjet printers.” * RAG & Banker’s Algorithm will have another
4. Some categories may only have one exclusive s4 episode
resource.
5. The kernel keeps track of which
resources are free and which are
allocated, to which process they are
allocated, and a queue of processes
waiting for this resource to become
available for all kernel-managed
resources. Mutexes or wait() and
signal() calls can be used to control
application-managed resources (i.e.
binary or counting semaphores. )
6. When every process in a set is waiting
for a resource that is currently
assigned to another process in the set,
the set is said to be deadlocked.

Necessary conditions

1. Mutual Exclusion
2. Hold & Wait
3. No Pre-emption
4. Circular Wait

Deadlock Handling

1. Deadlock Prevention:
a. Elimination of any of the
necessary conditions
b. Detect & Recover
c. Static Process
2. Deadlock Avoidance
a. Eliminate Mutual
Exclusion: It is not
possible to dis-satisfy the
mutual exclusion because
some resources, such as

You might also like