Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email:...

9
Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: [email protected] Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM. TA: Chen Yu Email: yuchen@cs.ucf.edu Office: HEC 354. Office hours: M, Wd 1.00 – 3:00 PM. 1

Transcript of Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email:...

Page 1: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Advanced Operating Systems - Spring 2009Lecture 14 – February 25, 2009Dan C. Marinescu

Email: [email protected]: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.

TA: Chen YuEmail: [email protected]: HEC 354. Office hours: M, Wd 1.00 – 3:00 PM.

1

Page 2: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Last, Current, Next Lecture Last time:

CPU Scheduling

Today M/M/m systems Scheduling Algorithms Memory management

Next time: Caching and Virtual Memory

2

Page 3: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Scheduling algorithms

A scheduling problems is defined by : The machine environment A set of side constrains and characteristics The optimality criterion

Machine environments: 1 One-machine. P Parallel identical machines Q Parallel machines of different speeds R Parallel unrelated machines O Open shop. m specialized machines; a job requires a

number of operations each demanding processing by a specific machine

F Floor shop

)()(

)(

),,(

Page 4: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

One-machine environment

n jobs 1,2,….n. pj amount of time required by job j.

rj the release time of job j, the time when job j is available for processing.

wj the weight of job j.

dj due time of job j; time job j should be completed.

A schedule S specifies for each job j which pj units of time are used to process the job.

CSj the completion time of job j under schedule S.

The makespan of S is: CSmax = max CS

j The average completion time is

n

j

SjCn 1

1

Page 5: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

One-machine environment (cont’d)

Average weighted completion time:Optimality criteria minimize:

the makespan CSmax

the average completion time :The average weighted completion time:

the lateness of job j maximum lateness of any

job under schedule S. Another optimality criteria, minimize maximum lateness.

n

j

SjjCw

1

n

j

SjC

1

n

j

SjjCw

1

Sj

nj LL 1max max j

Sjj dCL

Page 6: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Priority rules for one machine environmentTheorem: scheduling jobs according to SPT – shortest

processing time is optimal for

Theorem: scheduling jobs in non-decreasing order of is optimal for

jjCw||1 j

j

p

w

jC||1

Page 7: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Earliest deadline first (EDF)Dynamic scheduling algorithm for real-time OS. When a scheduling event occurs (task finishes, new

task released, etc.) the priority queue will be searched for the process closest to its deadline. This process will then be scheduled for execution next.

EDF is an optimal scheduling preemptive algorithm for uniprocessors, in the following sense: if a collection of independent jobs, each characterized by an arrival time, an execution requirement, and a deadline, can be scheduled (by any algorithm) such that all the jobs complete by their deadlines, the EDF will schedule this collection of jobs such that they all complete by their deadlines.

7

Page 8: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

EDF

8

11

n

j jp

djU

Process Execution Time Period

P1 1 8

P2 2 5

P3 4 10

The schedulability test for EDF is:

In this case U = 1/8 +2/5 + 4/10 = 0.925 = 92.5%

It has been proved that the problem of deciding if it is possible to schedule a set of periodic processes is NP-hard if the periodic processes use semaphores to enforce mutual exclusion.

Page 9: Advanced Operating Systems - Spring 2009 Lecture 14 – February 25, 2009 Dan C. Marinescu Email: dcm@cs.ucf.edudcm@cs.ucf.edu Office: HEC 439 B. Office.

Priority InversionA high priority process is blocked by a lower

priority one.Example: J1 and J3 share a data structure

guarded by a binary semaphore S.prty(J1) > prty(J2) > prty(J3).J1 in initiated while J3 is in its critical sectionWhen J1 attempts to enter the critical section it is

blocked.The duration of this blocking cannot be determined

as because J3 can be preempted by a higher priority job J2. prty

9