CPU SCHEDULING

GUIDED BY:
MR. VENKATESWARAN.R (ASST.   PROFESSOR M.TECH)



CREATED BY:
VINOTH.J
SARAVANA KUMAR.R
KARTHICK SEKAR.S
ASIR ALLOSANAI GANA SEKAR
MUTHURAMALINGAM.E
MUNEESWARAN.M


INFANT JESUS COLLEGE OF ENGINEERING
OVERVIEW

ď‚— Basic Concepts
ď‚— Scheduling Criteria
ď‚— Scheduling Algorithms
ď‚— Multiple-Processor Scheduling
ď‚— Operating Systems Examples
OVERVIEW

ď‚— In computer science, scheduling is the method by
 which threads, processes or data flows are given
 access to system resources (e.g. processor time,
 communications bandwidth). This is usually done to
 load balance a system effectively or achieve a target
 quality of service.
OVERVIEW

ď‚— Throughput:
ď‚— No of processes that complete the execution per unit
  time
ď‚— Response time: Amount of time it takes from
  when a request was submitted until the first
  response is produced
ď‚— Waiting time:Amount of time a process has been
  waiting in the ready queue Response time = waiting
  time + execution time
Types of scheduling methods


ď‚— Preemptive scheduling:A higher priority process
  can preempt a currently running low priority process
  to avoid priority inversion
ď‚— Nonpreemptive scheduling:A higher priority
  process waits a currently running process to finish
  regardless of the priority e.g., FCFS
Types of scheduling methods

ď‚— Long and medium term scheduling
ď‚— Long term scheduling: which determines which
  programs are admitted to the system for execution
  and when, and which ones should be exited.
ď‚— Medium term scheduling: which determines when
  processes are to be suspended and resumed;
ď‚— Short term scheduling (or dispatching): which
  determines which of the ready processes can have
  CPU resources, and for how long.
Single Processor Scheduling Algorithms

ď‚— First Come, First Served (FCFS)
ď‚— Shortest Job First (SJF)
ď‚— Priority
ď‚— Round Robin (RR)
First Come, First Served (FCFS)


ď‚— First Come, First Served (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.
Example
MERITS AND DEMERITS

ď‚— MERITS:Easy to understand and easy to program
ď‚— It is fair
ď‚— DEMERITS:
ď‚— Does not perform well in real systems
ď‚— Ignores the service time request and all other criteria
Shortest-Job-First (SJR) Scheduling

 1. non preemptive – once CPU given to the
  process it cannot be preempted until completes its
  CPU burst.
 2. preemptive – if a new process arrives with CPU
  burst length less than remaining time of current
  executing process, preempt. This scheme is know as
  the Shortest-Remaining-Time-First (SRTF).
 SJF is optimal – gives minimum average waiting
  time for a given set of processes.
Example
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
  CPUexecution time
ď‚— Short duration processes will starve longer ones
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)
Example
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.
Round Robin (RR)

ď‚— 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.
ď‚— Performance
ď‚—     1. q large _ FIFO
ď‚—     2. q small _ q must be large with respect to
  context switch, otherwise overhead is too high.
Example
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.
Multilevel Queue Scheduling
Multilevel Feedback Queue

ď‚— A process can move between the various queues;
ď‚— Multilevel-feedback-queue scheduler defined by
 the following parameters:
ď‚— 1. number of queues
ď‚— 2. scheduling g algorithms for each queue
Example of Multilevel Feedback Queue


             Scheduling algorithm         CPU Overhead          Throughput     Turnaround time         Response time




             First In First Out     Low                  Low                 High                Low




             Shortest Job First     Medium               High                Medium              Medium




             Priority based
                                    Medium               Low                 High                High
             scheduling




             Round-robin scheduling High                 Medium              Medium              High




             Multilevel Queue
                                    High                 High                Medium              Medium
             scheduling
Multiprocessor Scheduling

ď‚— '' On a multiprocessor, scheduling is two
 dimensional. The scheduler has to decide which
 process to run and which CPU to run it on. This extra
 dimension greatly complicates scheduling on
 multiprocessors.
OPERATING SYSTEM EXAMPLES

ď‚— Windows
ď‚— Very early MS-DOS and Microsoft Windows systems
 were non-multitasking, and as such did not feature a
 scheduler. Windows 3.1x used a non-preemptive
 scheduler, meaning that it did not interrupt
 programs.
OPERATING SYSTEM EXAMPLES

ď‚— Mac OS
ď‚— Mac OS 9 uses cooperative scheduling for threads,
 where one process controls multiple cooperative
 threads, and also provides preemptive scheduling for
 MP tasks.
CONCLUSION

ď‚— The above mentioned are the various CPU
 scheduling used in the present day. These algorithms
 are inherited based on the recuirement of the
 processor.

Cpu scheduling

  • 1.
    CPU SCHEDULING GUIDED BY: MR.VENKATESWARAN.R (ASST. PROFESSOR M.TECH) CREATED BY: VINOTH.J SARAVANA KUMAR.R KARTHICK SEKAR.S ASIR ALLOSANAI GANA SEKAR MUTHURAMALINGAM.E MUNEESWARAN.M INFANT JESUS COLLEGE OF ENGINEERING
  • 2.
    OVERVIEW ď‚— Basic Concepts ď‚—Scheduling Criteria ď‚— Scheduling Algorithms ď‚— Multiple-Processor Scheduling ď‚— Operating Systems Examples
  • 3.
    OVERVIEW ď‚— In computerscience, scheduling is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). This is usually done to load balance a system effectively or achieve a target quality of service.
  • 4.
    OVERVIEW ď‚— Throughput: ď‚— Noof processes that complete the execution per unit time ď‚— Response time: Amount of time it takes from when a request was submitted until the first response is produced ď‚— Waiting time:Amount of time a process has been waiting in the ready queue Response time = waiting time + execution time
  • 5.
    Types of schedulingmethods ď‚— Preemptive scheduling:A higher priority process can preempt a currently running low priority process to avoid priority inversion ď‚— Nonpreemptive scheduling:A higher priority process waits a currently running process to finish regardless of the priority e.g., FCFS
  • 6.
    Types of schedulingmethods ď‚— Long and medium term scheduling ď‚— Long term scheduling: which determines which programs are admitted to the system for execution and when, and which ones should be exited. ď‚— Medium term scheduling: which determines when processes are to be suspended and resumed; ď‚— Short term scheduling (or dispatching): which determines which of the ready processes can have CPU resources, and for how long.
  • 7.
    Single Processor SchedulingAlgorithms ď‚— First Come, First Served (FCFS) ď‚— Shortest Job First (SJF) ď‚— Priority ď‚— Round Robin (RR)
  • 8.
    First Come, FirstServed (FCFS) ď‚— First Come, First Served (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.
  • 9.
  • 10.
    MERITS AND DEMERITS ď‚—MERITS:Easy to understand and easy to program ď‚— It is fair ď‚— DEMERITS: ď‚— Does not perform well in real systems ď‚— Ignores the service time request and all other criteria
  • 11.
    Shortest-Job-First (SJR) Scheduling 1. non preemptive – once CPU given to the process it cannot be preempted until completes its CPU burst.  2. preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF).  SJF is optimal – gives minimum average waiting time for a given set of processes.
  • 12.
  • 13.
    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 CPUexecution time  Short duration processes will starve longer ones
  • 14.
    Priority Scheduling ď‚— TheSJF 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)
  • 15.
  • 16.
    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.
  • 17.
    Round Robin (RR) ď‚—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. ď‚— Performance ď‚— 1. q large _ FIFO ď‚— 2. q small _ q must be large with respect to context switch, otherwise overhead is too high.
  • 18.
  • 19.
    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.
  • 20.
  • 21.
    Multilevel Feedback Queue ď‚—A process can move between the various queues; ď‚— Multilevel-feedback-queue scheduler defined by the following parameters: ď‚— 1. number of queues ď‚— 2. scheduling g algorithms for each queue
  • 22.
    Example of MultilevelFeedback Queue Scheduling algorithm CPU Overhead Throughput Turnaround time Response time First In First Out Low Low High Low Shortest Job First Medium High Medium Medium Priority based Medium Low High High scheduling Round-robin scheduling High Medium Medium High Multilevel Queue High High Medium Medium scheduling
  • 23.
    Multiprocessor Scheduling ď‚— ''On a multiprocessor, scheduling is two dimensional. The scheduler has to decide which process to run and which CPU to run it on. This extra dimension greatly complicates scheduling on multiprocessors.
  • 24.
    OPERATING SYSTEM EXAMPLES ď‚—Windows ď‚— Very early MS-DOS and Microsoft Windows systems were non-multitasking, and as such did not feature a scheduler. Windows 3.1x used a non-preemptive scheduler, meaning that it did not interrupt programs.
  • 25.
    OPERATING SYSTEM EXAMPLES ď‚—Mac OS ď‚— Mac OS 9 uses cooperative scheduling for threads, where one process controls multiple cooperative threads, and also provides preemptive scheduling for MP tasks.
  • 26.
    CONCLUSION ď‚— The abovementioned are the various CPU scheduling used in the present day. These algorithms are inherited based on the recuirement of the processor.