Lecture 21 Introduction to Process Scheduling Review Processes

  • Slides: 17
Download presentation
Lecture 21: Introduction to Process Scheduling

Lecture 21: Introduction to Process Scheduling

Review: Processes & Threads • Resource ownership – Process or Task • Scheduling/execution –

Review: Processes & Threads • Resource ownership – Process or Task • Scheduling/execution – Thread or lightweight process One process, one thread (MS-DOS) Multiple processes, one thread per process (Unix) One process, multiple threads (Java Runtime) Multiple processes, multiple threads (W 2 K, Solaris, Linux)

Review: Single Threaded and Multithreaded Process Models

Review: Single Threaded and Multithreaded Process Models

Review: Process/Thread States • Possible process states – running – blocked – ready

Review: Process/Thread States • Possible process states – running – blocked – ready

Process behavior • Different Types of jobs have different demands – a CPU-bound process

Process behavior • Different Types of jobs have different demands – a CPU-bound process – an I/O bound process

Process Scheduling • When to run a different process? • Which one to run?

Process Scheduling • When to run a different process? • Which one to run?

When to schedule process • • • New process is created Process terminates A

When to schedule process • • • New process is created Process terminates A process blocks on I/O, semaphore, etc. I/O interrupt occurs Hardware clock interrupts

Preemptive vs. Non-preemptive • Non-preemptive Scheduling: Processes run until they have finished or block

Preemptive vs. Non-preemptive • Non-preemptive Scheduling: Processes run until they have finished or block for I/O • Preemptive Scheduling: Can forcibly suspend a process and switch to another – Hardware Clock Interrupt helps in implementing preemption

Categories of Process Scheduling • Batch Systems (Compute Servers) – Many processes, not interactive,

Categories of Process Scheduling • Batch Systems (Compute Servers) – Many processes, not interactive, throughput is important • Interactive Systems – PC • Real Time Systems – Guaranteed response times, meet deadlines

Scheduling Algorithm Goals • All Systems – Fairness – giving each process a fair

Scheduling Algorithm Goals • All Systems – Fairness – giving each process a fair share of the CPU – Policy enforcement – seeing that stated policy is carried out – Balance – keeping all parts of the system busy

Scheduling Algorithm Goals • Batch Systems – Throughput – maximize jobs per hour –

Scheduling Algorithm Goals • Batch Systems – Throughput – maximize jobs per hour – Turnaround time – minimize time between submission and termination – CPU utilization – keep the CPU busy all the time

Scheduling Algorithm Goals • Interactive Systems – Response time – respond to requests quickly

Scheduling Algorithm Goals • Interactive Systems – Response time – respond to requests quickly – Proportionality – meet users’ expectations

Scheduling Algorithm Goals • Real-time Systems – Meeting deadlines – avoid losing data –

Scheduling Algorithm Goals • Real-time Systems – Meeting deadlines – avoid losing data – Predictability – avoid quality degradation in multimedia systems

First Come First Serve (FCFS) • Maintain queue of processes • Schedule first in

First Come First Serve (FCFS) • Maintain queue of processes • Schedule first in queue • Scheduled job executes until it finishes or blocks for I/O • Simple, easy to implement • Not good for mix of short and long jobs – Example: a short job arriving soon after a long one

FCFS Arrival time CPU burst 0 P 1: 4 36 8 112 1 13

FCFS Arrival time CPU burst 0 P 1: 4 36 8 112 1 13 P 2: 23 40 2 16 P 3: 4 20 112 40 1 20 P 4: 2 150 3 10 1 0 I/O burst

FCFS 0 P 1: 4 36 8 112 1 13 P 2: 23 40

FCFS 0 P 1: 4 36 8 112 1 13 P 2: 23 40 2 16 P 3: 4 20 112 40 1 20 P 4: 2 150 3 10 1 Which process goes next? P 1 idle P 2 P 3 P 4 0 4 13 36 40 42

FCFS Time next ready 40 0 P 1: 4 36 8 112 1 76

FCFS Time next ready 40 0 P 1: 4 36 8 112 1 76 13 P 2: 23 40 2 60 16 P 3: 4 20 112 40 1 192 20 P 4: 2 150 3 10 1 Which process goes next? P 1 idle P 2 P 3 P 4 0 4 13 36 40 42