cpu scheduling l.
Download
Skip this Video
Download Presentation
CPU Scheduling

Loading in 2 Seconds...

play fullscreen
1 / 28

CPU Scheduling - PowerPoint PPT Presentation


  • 474 Views
  • Uploaded on

CPU Scheduling. Chapter 7. CPU Scheduling. Basic Concepts Scheduling Criteria Scheduling Algorithms FCFS (FIFO) SJN & SRTN Priority Scheduling Round Robin Scheduling Multilevel Queue Multilevel Feedback Queue. CPU Scheduling.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CPU Scheduling' - nemo


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cpu scheduling

CPU Scheduling

Chapter 7

A. Berrached:CMS:UHD

cpu scheduling2
CPU Scheduling
  • Basic Concepts
  • Scheduling Criteria
  • Scheduling Algorithms
    • FCFS (FIFO)
    • SJN & SRTN
    • Priority Scheduling
    • Round Robin Scheduling
    • Multilevel Queue
    • Multilevel Feedback Queue

A. Berrached:CMS:UHD

cpu scheduling3
CPU Scheduling
  • A multiprogramming OS allows more than one process to be loaded in main memory at a time.
  • Processes share the CPU using time-multiplexing
  • A process execution consists of a cycle of CPU computation--I/O operations.
  • I/O operations require orders of magnitude more time to complete.
  • Basic Idea: When the running process requests an I/O operation, allocate CPU to another process.

A. Berrached:CMS:UHD

cpu scheduler
CPU Scheduler
  • CPU Scheduler: that part of the Process Manager than is responsible for
    • handling removal of running process from CPU
    • Selection of another process

Two major issues:

  • Scheduling mechanism: how is it all done?
  • Scheduling policy:
    • when is it time for a process to be removed from CPU?
    • Which ready process should be allocated the CPU next?

A. Berrached:CMS:UHD

scheduling mechanism
Scheduling Mechanism

A. Berrached:CMS:UHD

scheduling mechanism cntd
Scheduling Mechanism CNTD

Three parts:

  • enqueuer
  • dispatcher
  • context-switcher

Data Structures:

  • Process Descriptor
  • Ready List

A. Berrached:CMS:UHD

scheduling mechanism cntd7
Scheduling Mechanism CNTD
  • When a process is moved to the Ready-List
    • Process Descriptor (PD) is updated
    • the enqueuer places a pointer to PD in the Ready-List
  • When the Scheduler switches CPU from one process to another process
    • the Context-Switcher saves the state of the current process in its PD.
  • How context-switching occurs depends on how CPU multiplexing technique used:
    • voluntary multiplexing
    • involuntary multiplexing

A. Berrached:CMS:UHD

scheduling mechanism cntd8
Scheduling Mechanism CNTD
  • Voluntary multiplexing: Running process gives up CPU voluntarily
    • context-switcher is invoked by running process.
  • Involuntary multiplexing: an interrupt causes running process to be removed from CPU.
    • Interrupt generated by an I/O operation requested by another process.
    • Most commonly: a timer generated interrupt.
    • In either case, interrupt handler invokes context-switcher.

A. Berrached:CMS:UHD

scheduling mechanism dispatcher
Scheduling Mechanism--Dispatcher
  • After state of "old" process is saved by context-switcher, the CPU is allocated to the Dispatcher
    • Dispatcher state is loaded on CPU
  • Dispatcher selects one of the ready processes enqueued in the Ready-List.
  • Dispatcher performs another context-switch from itself to selected process (saves its state and loads state of selected process).
  • The Process Descriptor of selected process is changed from Ready to Running.

A. Berrached:CMS:UHD

process scheduling
Process Scheduling

A. Berrached:CMS:UHD

scheduling policy criteria
Scheduling Policy Criteria

A. Berrached:CMS:UHD

optimization criteria
Optimization Criteria

A. Berrached:CMS:UHD

fcfs scheduling cont
FCFS Scheduling (cont.)

A. Berrached:CMS:UHD

shortest job next sjn scheduling
Shortest-Job-Next (SJN) Scheduling

SJN is optimal – gives minimum average waiting time for a given set of processes

A. Berrached:CMS:UHD

example of non preemptive sjn
Example of Non-Preemptive SJN

2.0

A. Berrached:CMS:UHD

example of preemptive sjn
Example of Preemptive SJN

2.0

A. Berrached:CMS:UHD

priority scheduling
Priority Scheduling

A. Berrached:CMS:UHD

round robin rr scheduling
Round Robin (RR) Scheduling

A. Berrached:CMS:UHD

deadline scheduling
Deadline Scheduling
  • Real Time Systems
    • Processes must complete their task by specific deadlines
    • Main performance criteria
    • Scheduler must have complete knowledge of service time of each process
      • All function must be predictable– no virtual memory
    • A process is admitted to ready list only if OS can guarantee deadline can be met.

A. Berrached:CMS:UHD

example
Example

Process Service Time Deadline

0 350 575

1 125 550

2 475 1050

3 250 none

4 75 200

A. Berrached:CMS:UHD

multi level queue
Multi-Level Queue
  • Extension of priority scheduling, which also combines other strategies
  • Ready list is partitioned into multiple sub-lists
  • Each process is assigned to a queue based on some criteria (type, priority, etc.)
    • E.g. one Q for foreground processes and one for background processes
  • Scheduler: * in-queue strategy

* cross-queue strategy

    • E.g. In-queue strategy: RR for foreground Q and FCFS for background A
    • Cross-queue strategy: Serve higher-level processes first

A. Berrached:CMS:UHD

multi level queue24
Multi-Level Queue
  • Example:
    • Cross-Queue Strategy: Each queue get a percentage of CPU time (in a round robin fashion) which it can schedule among its processes.
    • E.g. Level 1: 80% of CPU time

Level 2: 20% of CPU time

A. Berrached:CMS:UHD

multi level feedback queue
Multi-Level Feedback Queue

A. Berrached:CMS:UHD

example multi level feedback queue
Example:Multi-Level Feedback Queue
  • Gives shorter jobs higher priority without needing to predict a job’s service time requirement.

A. Berrached:CMS:UHD

bsd unix scheduling
BSD UNIX Scheduling
  • Multiple-level feedback queue approach
  • 32 queues
  • System processes are placed in Q0 – Q7
  • User processes are placed in Q8 – Q31
  • Dispatcher always selects a process from highest priority queue to run
  • RR is used in each queue (time slice varies but always < 100μs)
  • A process’s changes over time: based on nice() system calls and process’s utilization of CPU.

A. Berrached:CMS:UHD

windows nt 2k
Windows NT/2K
  • Multiple-level feedback queues for thread scheduling
  • Priority to those threads that need very rapid response
  • 32 levels
  • 16 highest priority Qs are called real-time level queues
  • Next 15 Qs are variable-level queue
  • Lowest priority Q is called system-level Q.
  • System-level Q contains a single thread called zero-page thread. It is run only when there are no other runnable threads.
  • Scheduling goes from highest level down
  • Scheduling is preemptive: if a high-priority thread becomes runnable while a lower priority thread is running, the latter is preempted and the higher level thread will begin to use the processor

A. Berrached:CMS:UHD