1 / 14

Tutorial 4

Tutorial 4. Scheduling. Why do we need scheduling?. To manage processes according to requirements of a system, like: User responsiveness or Throughput Performance of a scheduler is determined mainly by: Context switch time Scheduling policy. 1, 2, 3, 4, 5, 6, Context Switch!.

tejano
Download Presentation

Tutorial 4

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. Tutorial 4 Scheduling

  2. Why do we need scheduling? • To manage processes according to requirements of a system, like: • User responsiveness or • Throughput • Performance of a scheduler is determined mainly by: • Context switch time • Scheduling policy

  3. 1, 2, 3, 4, 5, 6, Context Switch! • Switching from one process running on the CPU to another process • Saves all the registers of outgoing process (to memory), then loads all the registers of incoming process (from memory) • Can be time-costly; mostly hardware-dependent

  4. Scheduling • The mechanism that determines when the CPU will be allocated to processes, and in what order • Two classes of scheduling strategies: • Nonpreemptive (aka Batch) • Preemptive

  5. Non-preemptive policies • Allow any process to run to completion once it has been allocated to the CPU. Current process does not get interrupted. • Some examples: • First Come First Serve (FCFS) • Shortest Job Next (SJN) • Priority scheduling • Deadline scheduling

  6. Preemptive policies • Allow another process to interrupt current process if: • It has a higher priority • The time quantum has elapsed • Some examples: • Round Robin • Multiple-level Queues

  7. Scheduling examples • Given three threads, their execution times and I/O needs, apply scheduling policies • Threads are placed on ready queue in order: T1, T2 then T3 * Specific to Round Robin: • Time Quantum of 3ms • Context switch time considered negligible in this example

  8. First Come First Serve 1 2 3 2 3 3 CPU: 0 5 10 15 20 25 30 35 40 I/O: 2 3 3

  9. Shortest Job First (Nonpreemptive) 1 3 2 3 2 3 CPU: 0 5 10 15 20 25 30 35 40 I/O: 3 2 3

  10. Shortest Job First (Preemptive) 1 3 2 3 2 3 2 CPU: 0 5 10 15 20 25 30 35 40 I/O: 3 2 3

  11. Priority (Preemptive) 3 1 3 1 3 1 2 2 CPU: 0 5 10 15 20 25 30 35 40 I/O: 3 3 2

  12. 3 3 3 2 1 Round Robin 1 2 3 1 2 1 3 2 2 3 2 CPU: 0 5 10 15 20 25 30 35 40 I/O: 2 3 3

  13. Recapping Scheduling in Java Java 1.2.1 and prior (“green”) threads: • Threads are managed by Java VM • One thread runs at a time • Thread is only taken off the CPU when: • it yields • it blocks (on a resource) • it exits • a higher priority thread becomes runnable (not always)

  14. New-Style Scheduling in Java Post-1.2.1 versions of Java: • Threads are managed by the host OS • Allows multiple threads to run “concurrently” • Thread is taken off the CPU as in previous versions, but also • when its time quantum expires (if supported by OS)

More Related