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

Unit 1 Ch-B- CPU SCheduling

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

Unit 1 Ch-B- CPU SCheduling

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

Process Scheduling

By
I Ravindra kumar, B.Tech, M.Tech,(Ph.D.)
Assistant professor,
Dept of CSE, VNR VJIET
Process Scheduling
• Foundation and Scheduling objectives,
• Types of Schedulers,
• Scheduling criteria:
– CPU utilization,
– Throughput,
– Turnaround Time,
– Waiting Time,
– Response Time.
• Scheduling Algorithms:
– Pre-emptive and non-pre-emptive, FCFS, SJF, RR;
– Multiprocessor scheduling:
– Real Time scheduling: RM and EDF.
• objective of multiprogramming is to have some process
running at all times, so as to maximize CPU utilization.
• The objective of time-sharing is to switch the CPU among
processes so frequently that users can interact with each
program while it is running.
• A uniprocessor system can have only one running process.
• If more processes exist, the rest must wait until the CPU is
free and can be rescheduled.
Scheduling Queues:
• As processes enter the system, they are put into a job queue.
• The processes that are residing in main memory and are ready
and waiting to execute are kept on a list called the ready
queue
• The list of processes waiting for a particular I/O device is
called a device queue
Schedulers
• Long-term scheduler (or job scheduler) – selects which processes
should be brought into the ready queue
• Short-term scheduler (or CPU scheduler) – selects which process
should be executed next and allocates CPU
• Addition of Medium Term Scheduling
• Short-term scheduler is invoked very frequently (milliseconds)
– Þ (must be fast)
• Long-term scheduler is invoked very infrequently (seconds,
minutes)
– Þ (may be slow)
• The long-term scheduler controls the degree of multiprogramming
• Processes can be described as either:
– I/O-bound process – spends more time doing I/O than computations,
many short CPU bursts
– CPU-bound process – spends more time doing computations; few very
long CPU bursts
Context Switch
• When CPU switches to another process, the system must save the
state of the old process and load the saved state for the new
process via a context switch
• Context of a process represented in the PCB
• Context-switch time is overhead;
CPU Scheduling
• CPU–I/O Burst Cycle – Process execution consists of a cycle of
CPU execution and I/O wait
• Alternating Sequence of CPU And I/O Bursts
CPU Scheduler
• Selects from among the processes in memory that are ready to
execute, and allocates the CPU to one of them
• CPU scheduling decisions may take place when a process:
1.Switches from running to waiting state
2.Switches from running to ready state
3.Switches from waiting to ready
4.Terminates
– Scheduling under 1 and 4 is nonpreemptive
– All other scheduling is preemptive
Dispatcher
• Dispatcher module gives control of the CPU to the process selected
by the short-term scheduler;
• this involves:
– switching context
– switching to user mode
– jumping to the proper location in the user program to restart that program
• Dispatch latency – time it takes for the dispatcher to stop one
Scheduling Criteria
• CPU utilization – keep the CPU as busy as possible
• Throughput – No of processes that complete their execution per
time unit
• Turnaround time – amount of time to execute a particular
process
• Waiting time – amount of time a process has been waiting in the
ready queue
• Response time – amount of time it takes from when a request
was submitted until the first response is produced, not output
(for time-sharing environment)
• Max CPU utilization
• Max throughput
• Min turnaround time
• Min waiting time
• Min response time
• CPU Sheduling Algorithms:
– Completion Time (CT): This is the time when the
process completes its execution.
– Arrival Time (AT): This is the time when the process
has arrived in the ready state.
– Burst Time(BT):It is the amount of processing time
required by a process to execute a specific task or
unit of a job.
– A Gantt chart is defined as a graphical representation
of activity against time;
• CPU Scheduling Algorithms:
– FCFS: First come First Serve
• Disadvantage : Convoy effect
– SJF: Shortest job first
• Disadvantage : Not complete SJF
– SRTF: Shortest Remaining Time First
• Disadvantage : No Priority
– Priority:
• Disadvantage : Not Complete Priority
– Preemptive Priority:
• Disadvantage : Starvation
• Solution: Aging
• Aging uses Priority Inheritance Protocol
– Roundrobin:
Multilevel Queue CPU Scheduling
• Ready queue is partitioned into separate queues:
foreground (interactive) background (batch)
• Each queue has its own scheduling algorithm
– foreground – RR
– background – FCFS
• Scheduling must be done between the queues
• Fixed priority scheduling; (i.e., serve all from foreground
then from background).
– Possibility of starvation.
• Time slice – each queue gets a certain amount of CPU
time which it can schedule amongst its processes;
– i.e., 80% to foreground in RR
– 20% to background in FCFS
• Multilevel Feedback Queue
• A process can move between the various queues;
aging can be implemented this way
• Multilevel-feedback-queue scheduler defined by
the following parameters:
– number of queues
– scheduling algorithms for each queue
– method used to determine when to upgrade a
process
– method used to determine when to demote a
process
– method used to determine which queue a process
will enter when that process needs service
Algorithm Evaluation
• How do we select a CPU-scheduling algorithm for a
particular system?
• Our criteria may include several measures, such as:
– Maximize CPU utilization under the constraint that the
maximum response time is 1 second.
– Maximize throughput such that turnaround time is (on
average) linearly proportional to total execution time.
• Deterministic Modeling:
– takes a particular predetermined workload and defines
the performance of each algorithm for that workload.
• Queueing Models:
– The computer system is described as a network of
servers.
– Each server has a queue of waiting processes.
– The CPU is a server with its ready queue, as is the I/O
system with its device queues.
– Knowing arrival rates and service rates,
• we can compute utilization, average queue length, average
wait time, and so on.
– This area of study is called queueing-network
analysis.
• Simulations:
• Simulations involve programming a model of the
computer system.
• Software data structures represent the major
components of the system.
• The simulator has a variable representing a clock;
as this variable's value is increased,
– the simulator modifies the system state to reflect the
activities of the devices, the processes, and the
scheduler.
• As the simulation executes, statistics that
indicate algorithm performance are gathered and
printed.

You might also like