CPU Scheduling in Operating Systems: Types, Concepts, and Algorithms, Study notes of Computer Science

An overview of cpu scheduling in operating systems, including the types of resources in a multiprogramming system, cpu scheduling examples, scheduling concepts, and common scheduling algorithms such as first-come-first-served (fcfs) and shortest-job-first (sjf).

Typology: Study notes

Pre 2010

Uploaded on 09/24/2009

koofers-user-jkw
koofers-user-jkw 🇺🇸

10 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems
Operating Systems
CMPSC 473
CMPSC 473
CPU Scheduling
CPU Scheduling
February 12, 2008 - Lecture
February 12, 2008 - Lecture
8
8
Instructor: Trent Jaeger
Instructor: Trent Jaeger
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download CPU Scheduling in Operating Systems: Types, Concepts, and Algorithms and more Study notes Computer Science in PDF only on Docsity!

Operating SystemsOperating Systems

CMPSC 473 CMPSC 473

CPU Scheduling CPU Scheduling

February 12, 2008 - Lecture February 12, 2008 - Lecture 88

Instructor: Trent Jaeger Instructor: Trent Jaeger

  • Last class:
    • Threads
  • Today:
    • CPU Scheduling

Resources Types

  • Memory : Allocate portion of finite resource
    • Virtual memory tries to make this appear infinite
    • Physical resources are limited
  • I/O : Allocate portion of finite resource and time with

resource

  • Store information on disk
  • A time slot to store that information
  • CPU : Allocate time slot with resource
  • A time slot to run instructions
  • We will focus on CPU scheduling in the section

CPU Scheduling Examples

• Single process view

  • GUI request
    • Click on the mouse
  • Scientific computation
    • Long-running, but want to complete ASAP

• System view

  • Get as many tasks done as quickly as possible
  • Minimize waiting time for processes
  • Utilize CPU fully

Scheduling Problem

  • Choose the ready/running process to run at any time
    • Maximize “performance”
  • Model/estimate “performance” as a function
    • System performance of scheduling each process
      • f(process) = y
    • What are some choices for f(process)?
  • Choose the process with the best y
    • Estimating overall performance is intractable
      • E.g., scheduling so all tasks are completed as soon as possible

Scheduling Concepts

Preemptive vs Non-

preemptive

  • Can we reschedule a process that is actively running?
    • If so, we have a preemptive scheduler
    • If not, we have a non-preemptive scheduler
  • Suppose a process becomes ready
    • E.g., new process is created or it is no longer waiting
  • It may be better to schedule this process
    • So, we preempt the running process
  • In what ways could the new process be better?

Bursts

• A process runs in CPU and I/O Bursts

  • Run instructions (CPU Burst)
  • Wait for I/O (I/O Burst)

• Scheduling is aided by knowing the length of

these bursts

  • More later…

CPU Burst Duration

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 process and start another running

Scheduling Criteria

  • Utilization/efficiency: keep the CPU busy 100% of the time with useful work
  • Throughput: maximize the number of jobs processed per hour.
  • Turnaround time: from the time of submission to the time of completion.
  • Waiting time: Sum of times spent (in Ready qqueue) waiting to be scheduled on the CPU.
  • Response Time: time from submission till the first response is produced (mainly for interactive jobs)
  • Fairness: make sure each process gets a fair share of the CPU

Scheduling Algorithms

First-Come, First-Served (FCFS) Process Burst Time P 1 24 P 2 3 P 3 3

  • Suppose that the processes arrive in the order: P 1 , P 2 , P 3 The Gantt Chart for the schedule is:
  • Waiting time for P 1 = 0; P 2 = 24; P 3 = 27
  • Average waiting time: (0 + 24 + 27)/3 = 17 P 1 P 2 P 3 0 24 27 30

Reducing Waiting Time

Suppose that the processes arrive in the order P 2 , P 3 , P 1

  • The Gantt chart for the schedule is:
  • Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3
  • Average waiting time: (6 + 0 + 3)/3 = 3
  • Much better than previous case
  • Convoy effect short process behind long process P 2 P 3 P 1 0 3 6 30