1 / 12

Task scheduling

Task scheduling. What are the goals of a modern operating system scheduler, and how does Linux achieve them?. 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?

ccarmen
Download Presentation

Task scheduling

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 CPU’s 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., it’s 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)

More Related