Task scheduling - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Task scheduling

Description:

Exercise #1: write an application program which exhibits 'CPU bound' behavior ... write a program which would exhibit alternating behavior (becoming an I/O bound ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 13
Provided by: professora5
Category:

less

Transcript and Presenter's Notes

Title: Task scheduling


1
Task scheduling
  • What are the goals of a modern operating system
    scheduler, and how does Linux achieve them?

2
Types of scheduling
  • Stallings identifies three distinct kinds of
    process-scheduling decisions
  • Long-term which tasks will the system admit?
    When? And in what order?
  • Medium-term which tasks will be temporarily
    swapped out to disk? And when will they be
    swapped back in to main memory?
  • Short-term which of the ready-to-run tasks will
    next gain control of the processor?

3
When are decisions made?
  • Linux makes its short-term scheduling decisions
  • When a timer interrupt occurs
  • When an I/O request completes
  • When a system-call is invoked
  • When a signal is sent
  • Linux makes its longer-term scheduling decisions
  • When a task exits
  • When CPUs idle-time exceeds a given threshold

4
Goals
  • Specific scheduling policies are chosen to
    support desired system behaviors
  • There are multiple goals -- and sometimes they
    may even appear to be contradictory
  • So scheduling policies are a compromise

5
User-oriented goals
  • Rapid response-time
  • Short turnaround-times
  • Assured deadlines
  • Predictable performance

6
System-oriented goals
  • Optimum throughput
  • Maximum CPU utilization
  • Balanced resource allocation
  • Enforce priorities
  • Assure Fairness

7
Fairness algorithms
  • One fairness principle is known as FCFS
    (First-Come, First-Served), though it may not
    provide optimal throughput
  • Another way to implement fairness is
    round-robin scheduling (timeslicing) in which
    every task gets allocated an equal-size slice
    of the CPUs available time, and all tasks take
    their turn at executing

8
Task types
  • Some tasks are CPU bound
  • They regularly consume the entire amount of
    processor time that they are allotted
  • Some tasks are I/O bound
  • They seldom use up their entire timeslice, but
    instead sleep while awaiting an I/O request

9
How does kernel distinguish?
  • If the scheduler repeatedly gets invoked because
    a task has used up its timeslice, the kernel
    treats that task as CPU bound
  • If the scheduler repeatedly gets invoked because
    a task is going to sleep (i.e., its awaiting
    completion of an I/O request), then that task is
    treated as I/O bound

10
Responsiveness
  • To achieve improved responsiveness in interactive
    applications, an OS kernel can assign a higher
    priority to I/O bound tasks
  • Tasks that have higher priority will always get
    scheduled before any tasks that have lower
    priority get scheduled
  • However this could result in starvation

11
Dynamic priorities
  • Linux combines priority-based scheduling with
    round-robin scheduling
  • Linux allows priorities to be dynamically
    recomputed
  • Separate queues are used for tasks with differing
    priorities, while tasks that have equal priority
    are scheduled round-robin
  • Tasks can migrate between priorities

12
In-class exercises
  • Exercise 1 write an application program which
    exhibits CPU bound behavior
  • Exercise 2 write an application program which
    exhibits I/O bound behavior
  • Exercise 3 write a program which would exhibit
    alternating behavior (becoming an I/O bound task
    for awhile, then becoming a CPU bound task for
    awhile)
Write a Comment
User Comments (0)
About PowerShow.com