1. ( T E C H N I C A L P R E S E N TAT I O N S K I L L S )
CPU SCHEDULING
2. SHRI VAISHNAV VIDYAPEETH VISHWAVIDYALAYA
SHRI VAISHNAV INSTITUTE OF INFORMATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
Submitted By:
Yashita Namdeo
CSE – B
18100BTIT03158
Submitted To:
Mrs. Sonam Mehta
3. WHAT IS CPU SCHEDULING?
• Operating System manages a collection of processes.
• If a system has more processes and one CPU or more
processes with fewer CPU’s has to divide CPU time
among different processes.
• This is called CPU Scheduling
5. PROCESS STATES
• New State : process is under creation
• Ready State : waiting for CPU for execution
• Running State : under execution
• Termination : execution is completed
• Waiting/Block : waits for certain resource
• Suspend Wait : process waits in Secondary Memory
• Suspend Ready : moves from ready state to Secondary
Memory
6. NEED OF SCHEDULING?
• CPU scheduling is a process which allows one process
to use the CPU while the execution of another process is
on hold(in waiting state) due to unavailability of any
resource like I/O etc, thereby making full use of CPU.
• The aim of CPU scheduling is to make the system
efficient, fast and fair.
7. NEED OF SCHEDULING
• Whenever the CPU becomes idle, the operating system
must select one of the processes in the ready queue to
be executed.
• The selection process is carried out by the short-term
scheduler (or CPU scheduler).
• The scheduler selects from among the processes in
memory that are ready to execute, and allocates the
CPU to one of them.
Continue
8. OVERVIEW
• Short term scheduler : selects a process from ready
queue among the ready processes to execute on the
CPU.
• Based on the Scheduling Algorithm employed on the
system.
9. • CPU switching from one process to another requires
saving the state of the current process and having the
latest state of the next process. This is known as
Context Switching
10. • Dispatcher : the STS just selects the process which can
be assigned to the processor. The actual job of Context
Switching is done by dispatcher.
• Dispatch Latency : Time taken by dispatcher to stop
one process and start another process.
11. SCHEDULING CRITERIA
• Arrival Time ( AT )
• Burst Time ( BT / ET )
• Turn Around Time ( TAT )
• Waiting Time ( WT )
• Response Time ( RT )
• Completion Time ( CT )
12. • Arrival Time : time the process has arrived in RS.
• Burst Time/ Execution Time : time required by process
for its execution.
• Completion Time : time when process is completed.
• Turn Around Time : CT – AT
• Waiting Time : TAT – ET
• Response Time : AT – first response by CPU
• Throughput : no. of process that complete execution
per unit time.
• CPU Utilization : keep CPU as busy as possible.
13. TYPES OF SCHEDULING METHODS
• Preemptive – OS can force ( preempt ) a process from
CPU at anytime.
• Nonpreemptive – once a process is allocated the CPU,
it does not leave unless:
i. It has to wait( for I/O request)
ii. It terminates
14. SCHEDULING ALGORITHMS
• First Come First Serve ( FCFS )
• Shortest Job First ( SJF )
• Priority
• Round Robin ( RR )
15. FIRST COME FIRST SERVE
• First Come, First Serve (FCFS), is the simplest
scheduling algorithm, FIFO simply queues processes in
the order that they arrive in the ready queue.
• Throughput can be low, since long processes can hold
the CPU.
• It is based on Queuing.
• No prioritization occurs, thus this system has trouble
meeting process deadlines.
• Convey Effect – short process behind long process.
16.
17. MERITS AND DEMERITS
Merits
• Easy to understand and
easy to program.
• It is fair.
Demerites
• Does not perform well in
real systems.
• Ignores the service time
request and all criteria.
18. SHORTEST JOB FIRST
i. Non preemptive – once CPU given to the process it
cannot be preempted until completes its CPU burst.
ii. Preemptive – if a new process arrives with CPU burst
length less than remaining time of current executing
process, preempt. This scheme is known as the
Shortest – Remaining – Time – First (SRTF).
19.
20. MERITS AND DEMERITS
Merits
• SJF is optimal – gives
minimum average waiting
time for a given set of
processes.
Demerits
• Need to have a good
heuristic to guess the
next CPU execution time.
• Short duration processes
will starve longer ones.
21. PRIORITY SCHEDULING
• The SJF algorithm is a special case of the general
priority scheduling algorithm.
• A priority number(integer) is associated with each
process.
• The CPU is allocated to the process with the highest
priority (smallest integer = highest priority)
• Starvation (Infinity blocking) : low priority process may
never execute.
• Aging : as time progresses increases the priority of the
process.
22.
23. MERITS AND DEMERITS
Merits
• Simplicity
• Reasonable support for
priority.
• Suitable for applications
with varying time and
resource requirements.
Demerits
• Indefinite blocking or
starvation.
• A priority scheduling can
leave some low priority
waiting processes
indefinitely for CPU.
24. ROUND ROBIN
• Each process gets a small unit of CPU time ( time
quantum ), usually 10-100 milliseconds. After this time
has elapsed, the process is preempted and added to the
end of the ready queue.
25.
26. MERITS AND DEMERITS
Merits
• Fair allocation of CPU
across jobs.
• Low average waiting time
when job lengths vary.
Demerits
• It is suitable for task with
varied burst time. But for
task with same time
makes trouble.