Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)

Similar presentations


Presentation on theme: "Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)"— Presentation transcript:

1 Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)

2 Scheduling Example 3 (2) JobArrivesRun Time Memory 1 10.0 0.3 10 2 10.2 0.5 60 3 10.4 0.1 50 4 10.5 0.4 10 5 10.8 0.1 30 HOLDQ Ready / Running

3 Example 3 (Cont…) TimeEvent #Jobs Headway MM FreeTime Left 10.01 A,S9010.3 10.22 A,S10.23010.1 20.5 10.41 F20.14020.4 3 A,H 10.54 A,S10.13020.3 40.4 10.85 A,S20.15020.15 40.25 50.1 11.15 F30.13020.05 40.15 11.22 F20.059040.1 3 S4030.1 11.43 F20.150 4 F100 Must be memory size Must be 10.0+ sum of all Ri

4 T and W for Example 3 Job Run ArrivalFinish Ti Wi 1 0.310.010.4 0.4 1.33 2 0.510.211.2 1.0 2.0 3 0.110.411.4 1.0 10.0 4 0.410.511.4 0.9 2.25 5 0.110.811.1 0.3 3.0 ===== ===== 3.6 18.58 T = 0.72 W = 3.716

5 Scheduling Example 4 (1) Assume: FIFO Job Scheduling 100 K Main Memory Devices Processor Sharing Process Scheduling (Cont…)

6 Scheduling Example 4 (2) JobArrivesRun Time Memory Devices 1 10.0 0.3 102 2 10.2 0.5 601 3 10.4 0.1 504 4 10.5 0.4 102 5 10.8 0.1 303 HOLDQ Ready / Running

7 Example 4 (Cont…) TimeEvent #Jobs Headway MM FreeDevices Time Left 10.01 A,S90 31 0.3 10.22 A,S 10.230 21 0.1 2 0.5 10.41 F20.140 42 0.4 3 A,H 10.54 A,S10.130 22 0.3 4 0.4 10.85 A,H20.1530 22 0.15 4 0.25 11.12 F20.1590 34 0.1 5 S60 05 0.1 11.35 F20.190 33 0.1 4 F100 5 3 S50 1 11.43 F10.1100

8 T and W for Example 4 Job RunStartFinish Ti Wi 1 0.310.010.4 0.4 1.33 2 0.510.211.1 0.9 1.8 3 0.110.411.4 1.0 10.0 4 0.410.511.3 0.8 2.0 5 0.110.811.3 0.5 5.0 ===== ===== 3.6 20.13 T = 0.72 W = 4.026

9 Scheduling Example 5 (1) Assume: FIFO Job Scheduling 100 K Main Memory Devices Processor Sharing Process Scheduling (Cont…)

10 Scheduling Example 5 (2) JobArrivesRun Time Memory Tapes 1 1.0 0.5 302 2 1.2 1.0 501 3 1.3 1.5 501 4 1.4 2.0 202 5 1.7 0.5 303 6 2.1 1.0 302

11 Example 5 (Cont…) (1) TimeEvent #Jobs Headway MM FreeDevices Time Left 1.01 A,S70 31 0.5 1.22 A,S10.220 21 0.3 2 1.0 1.33 A,H20.0520 21 0.25 2 0.95 1.44 A,S20.050 01 0.2 2 0.9 4 2.0 1.75 A,H30.10 01 0.1 2 0.8 4 1.9 2.01 F30.130 22 0.7 4 1.8 2.16 A,S20.050 02 0.65 4 1.75 6 1.0

12 Example 5 (Cont…) (2) TimeEvent #Jobs Headway MM FreeDevices Time Left 4.052 F30.6550 14 1.1 3 S 0 06 0.35 3 1.5 5.16 F30.3530 24 0.75 3 1.15 6.64 F20.7550 43 0.4 5 S20 1 5 0.5 7.43 F20.470 25 0.1 7.55 F10.1100 5

13 T and W for Example 5 Job Run ArrivalFinish Ti Wi 1 0.51.02.0 1.0 2.0 2 1.01.24.05 2.85 2.85 3 1.51.37.4 6.1 4.06 4 2.01.46.6 5.2 2.6 5 0.51.77.5 5.8 11.6 6 2.12.15.1 3.0 3.0 ===== ===== 23.95 26.11 T = 3.99 W = 4.35

14 Job Scheduling Also known as FCFS: first come, first served Scheduling based on arrival time Non-preemptible discipline Fair – no job is given preferential treatment, and every arriving job eventually runs Whey is this policy bad for interactive users Wait HoldReady Run

15 Process Management A multiprogramming OS must interleave the execution of multiple jobs The OS must decide when each process gets to use each resource (CPU,disk, etc.) The scheduler decides “when”

16 Time Quantums How does the OS interleave execution of many processes on the CPU? Ans: Time slicing Quantum: Amount of time given to jobs when time sharing

17 Process States Running: Process currently has CPU Ready: Process could use CPU, if CPU were free Blocked: Process is waiting for some event to occur: I/O Completion Buffer available from another process Data arrives from network (More states will be discussed later.)

18 Process State Transitions Running ReadyBlocked Wakeup Block Timeout Dispatch Is there a maximum number of processes in any state?

19 Suspend and Resume Ready Running Suspended ReadySuspended blocked Blocked Wakeup Suspend Resume Event (e.g., I/O) completion Timeout Dispatch Suspend Resume

20 Process Control Block (PCB) One PCB per process, containing all information about that process Process Identifier (pid) Parent’s pid State (e.g., Running, Blocked in ReadyQ) Priority Time at which its execution started Amount of CPU time consumed so far Copy of all register contents when process was last suspended Main memory used by process (e.g., base and bound registers, page table pointer) Accounting information Room for pointers to PCB into a queue File descriptor table

21 Context Switch A Context Switch occurs when a process exchange is made between the ready and run queues: Must: Save the state of the running process AND Restore the state of the ready process Run Ready

22 What happens on a Context Switch? (1) 1.Hardware: Resets Program Counter (PC to that of the interrupt handler (IH), which is an address in the OS kernel Switches from user to supervisor mode 2.Kernel: Copies A’s state from CPU registers to A’s PCB Sets A’s state to Ready or Blocked Inserts A’s PCB on ReadyQ or BlockedQ 3.Scheduler selects a new process to run (B), based on its scheduling discipline (Contd…)

23 What happens on a Context Switch? (2) 4. Kernel: Sets B’s state to Running Copies B’s state from B’s PCB to CPU registers 5.Kernel transfers control to B and thereby switches from kernel back to user context What machine instructions can achieve number 5?

24 Preemption Two classes of scheduling disciplines Premptive Scheduler takes CPU away from running job and gives it to another job Preempt upon arrival of higher priority job Non-premptive

25 Process Scheduling Algorithms (1) 1. Round Robin (RR) Each process runs either until Its time quantum expires or It blocks to perform I/O 2. Processor Sharing (PS) Limit of RR as time quantum goes to zero (Like giving each CPU cycle to a different process, in round robin fashion) N processes scheduled by PS = each job runs on dedicated N-fold slower CPU. Thus, READY = RUNNING

26 Process Scheduling Algorithms (2) 3. Priority Each process is statically assigned a priority; run high before low priority 4. Dynamic Priority Same as #3, except priority level of each process can change dynamically 5. Inverse of the Remainder of the Quantum Position in ready queue is determined by the amount of time remaining in the time slice (e.g., if ¾ of time slice is left, the job moves ¼ ahead in the ready queue)

27 Process Scheduling Algorithms (3) 6. Multiple-Level Feedback Variant on the Round Robin Current processes are forced to wait until new jobs “catch up” in time, then all RR 7. System Balance Balance system between I/O bound and CPU bound jobs 8. Preference to Interactive jobs Interactive jobs have higher priority


Download ppt "Scheduling Example 3 (1) Assume: FIFO Job Scheduling 100 K Main Memory Processor Sharing Process Scheduling (Cont…)"

Similar presentations


Ads by Google