Docsity

High Performance Computing Lecture 18: Preemptive Scheduling Policies and Process Lifetime, Slides of Computer Science

Partial preview of the text

Download High Performance Computing Lecture 18: Preemptive Scheduling Policies and Process Lifetime and more Slides Computer Science in PDF only on Docsity!

High Performance Computing

Lecture 18

2

Preemptive Scheduling Policies

1. Round robin

 Maintain a FCFS ReadyQ  When the currently running process is preempted, schedule the process from the front of the ReadyQ  Insert the previously running process at the end of the ReadyQ  This is much fairer than any of the non- preemptive scheduling policies

4

Example: Multilevel Feedback

 Used in some kinds of UNIX

 A Preemptive, Priority-based policy

 Multilevel: OS maintains one readyQ per

priority level

 It schedules the process from the front of the highest priority non-empty queue

 Feedback: Priorities are not fixed

 A process could be moved to a lower/higher priority queue for fairness

5

Recall: Process Lifetime

 Process Lifetime: Time between fork() that

created the process and exit() that causes its

termination

7

Recall: Process Lifetime

 Process Lifetime: Time between fork() that

created the process and exit() that causes its

termination

 At any given point in time, a running process

is executing either in user mode or in system

mode

 Can find out the total CPU time used by a

process, as well as CPU time in user mode,

CPU time in system mode

8

Time: Process virtual and Elapsed

P1 P2 (^) P3 (^) P1 P P1 P : Running in user mode : Running in system mode Elapsed time Process P virtual time Wallclock time Real time time Process P virtual time

10

Exceptions

 Certain exceptional events that occur during

program execution, handled by the

processor HW

 There are two kinds of exceptions

  1. Traps  Page fault, Divide by zero, System call
  2. Interrupts  Timer, keyboard, disk : Synchronous, software generated : Asynchronous, hardware generated

11

What Happens on an Exception

1. Hardware

  • Saves processor state
  • Transfers control to corresponding piece of OS code, called the exception handler

2. Software (exception handler)

  • Takes care of the situation as appropriate
  • Ends with return from exception instruction

3. Hardware (execution of RFE instruction)

  • Restores the saved processor state
  • Transfers control back to the saved PC value