Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems.

Similar presentations


Presentation on theme: "Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems."— Presentation transcript:

1 Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems

2 COP 5994 - Operating Systems2 Process Lifecycle

3 COP 5994 - Operating Systems3 Processor scheduling policy Decides which process runs at given time scheduling goals –Maximize processor utilization –Minimize response-time to user –Also: Maximize throughput Complete process by given deadline

4 COP 5994 - Operating Systems4 Concept: CPU And I/O Bursts

5 COP 5994 - Operating Systems5 Histogram of CPU-burst Times

6 COP 5994 - Operating Systems6 Concept: Preemption Preemptive scheduling –Process can be removed from current processor improved response times important for interactive environments –(preempted process remains in memory) Non-preemptive scheduling –Process runs to completion or yield unimportant processes can block important ones indefinitely

7 COP 5994 - Operating Systems7 Concept: Priority Static priorities –Priority assigned to a process does not change Easy to implement, low overhead Not responsive to changes in environment Dynamic priorities –Responsive to change –Promote smooth interactivity –Incur more overhead than static priorities Justified by increased responsiveness

8 COP 5994 - Operating Systems8 Scheduling Criteria CPU utilization –keep the CPU as busy as possible Throughput –# of processes that complete per time unit Turnaround time –amount of time to execute a process Waiting time –time a process has been waiting in the ready queue Response time –time from request until first response is produced

9 COP 5994 - Operating Systems9 Scheduling Objectives Summary Several goals common to most schedulers –Fairness –Predictability –Scalability

10 COP 5994 - Operating Systems10 Scheduling Criteria Consider run-time behavior of process –Compute vs. I/O wait Process categories: –Processor-bound –I/O-bound –Batch processes no user interaction –Interactive processes frequent user interaction

11 COP 5994 - Operating Systems11 Scheduling Algorithms Decide when and for how long a process runs Make choices about –Preemptibility –Priority –Running time –Run-time-to-completion –Fairness

12 COP 5994 - Operating Systems12 –Simplest scheme –Processes dispatched according to arrival time –Non-preemptive –Rarely used as primary scheduling algorithm First-In-First-Out Scheduling

13 COP 5994 - Operating Systems13 Round-Robin Scheduling –Based on FIFO –Processes run only for a limited time slice or quantum Must be preemptible Context switch overhead must be minimized –Often used as part of more complex algorithms

14 COP 5994 - Operating Systems14 RR Factor: time quantum size –Determines response time to interactive requests –Very large quantum size Processes run for long periods Degenerates to FIFO –Very small quantum size System spends most time context switching –Compromise: Long enough for normal processes to issue I/O request Batch processes still get majority of processor time

15 COP 5994 - Operating Systems15 Shortest-Process-First Scheduling process with smallest time to finish goes first –Lower average wait time than FIFO Reduces the number of waiting processes –Potentially large variance in wait times –Non-preemptive Results in slow response times to new processes –Relies on estimates of time-to-completion Can be inaccurate or falsified –Unsuitable for use in modern interactive systems

16 COP 5994 - Operating Systems16 Improves upon SPF scheduling also considers priority –Considers how long process has been waiting –Prevents indefinite postponement –Still non-preemptive Highest-Response-Ratio-Next Scheduling waiting-time + service-time service-time priority =

17 COP 5994 - Operating Systems17 Shortest-Remaining-Time Scheduling Preemptive version of SPF –Shorter arriving process preempts running process –Problems: Very large variance of response times: –long processes wait even longer than under SPF Context-switching overhead can become significant –Short incoming process can preempt a running process that is near completion

18 COP 5994 - Operating Systems18 Scheduling Realities Different processes have different needs –Short I/O-bound interactive processes should generally run before processor- bound batch processes –Behavior patterns not immediately obvious to the scheduler

19 COP 5994 - Operating Systems19 Example: Selfish RR Scheduling process has priority 2 queues: –Holding vs. Active process enters into holding queue –Increases priority as process ages moves to active queue when it reaches priority of other processes in active queue RR scheduling in active queue

20 COP 5994 - Operating Systems20 Multilevel Feedback Queues

21 COP 5994 - Operating Systems21 Multilevel Feedback Queues Arriving processes enter the highest-level queue with higher priority Long processes descend into lower levels –Gives short and I/O-bound processes higher priority –Long processes will run when short and I/O-bound processes terminate Process entering a higher-level queue preempt running process Each queue has own scheduler –Typical: FIFO or RR

22 COP 5994 - Operating Systems22 Fair Share Scheduling

23 COP 5994 - Operating Systems23 Deadline Scheduling –Process must complete by specific time –Used when results would be useless if not delivered on-time –Difficult to implement Must plan resource requirements in advance Incurs significant overhead Service provided to other processes can degrade

24 COP 5994 - Operating Systems24 Real-time Scheduling Processes have timing constraints Soft real-time system Does not guarantee that timing constraints will be met For example, multimedia playback Hard real-time system Timing constraints will always be met modes of operation: –periodic execution of processes –response to external event catastrophic result if constraint is not met

25 COP 5994 - Operating Systems25 Static Real-Time Scheduling –Does not adjust priorities over time Low overhead Suitable for systems where conditions rarely change –used for hard real-time systems –Rate-monotonic (RM) scheduling priority-based RR scheduling Process priority increases monotonically with the frequency with which it must execute –Deadline RM scheduling priority can be adjusted for deadline

26 COP 5994 - Operating Systems26 Dynamic Real-Time Scheduling –Adjusts priorities to changing conditions –has overhead: must ensure no missed deadlines Priorities are based on processes’ deadlines –Earliest-deadline-first (EDF) Preemptive, always dispatch the process with the earliest deadline –Minimum-laxity-first Similar to EDF, but bases priority on laxity L = Deadline – (currentTime + timeToComplete) scenario: L = 0scenario: L negative ?

27 COP 5994 - Operating Systems27 Java Thread Scheduling threads have priority –set by programmer queue per priority level –round-robin scheduling arriving thread of higher thread preempts implemented via –time slice –yield operation

28 COP 5994 - Operating Systems28 Java Thread Scheduling

29 COP 5994 - Operating Systems29 Linux Task Scheduling Linux 2.6: –O(1) scheduler –scheduling operations run in constant time –improve scalability because execution time independent of number of tasks in the system system timer interrupt every 1ms (IA32) –to update kernel data structure

30 COP 5994 - Operating Systems30 Linux Task Priority task has static priority –-20 to 19 (lower number is higher priority) scheduling is based on effective priority –adjusted for execution behavior ratio of sleep vs. run time –task that sleeps more is given higher priority

31 COP 5994 - Operating Systems31 Preemptive Scheduler variable time slice between 10 and 200ms –higher priority gets larger time slice each task runs until either: –its time slice expires –a higher priority process becomes runnable –the process blocks tasks placed in run queue levels for each priority –priority array refers to each level sub-queue –RR scheduling for priority level sub-queue

32 COP 5994 - Operating Systems32 Scheduler priority array

33 COP 5994 - Operating Systems33 Indefinite Postponement each task executes once per epoch –epoch duration limited by starvation limit default: 10 * tasks-in-run-queue seconds –when starvation limit is reached tasks run that have not executed in the epoch epoch ends, new epoch starts –guarantees that low-priority tasks will run eventually

34 COP 5994 - Operating Systems34 Linux Multiprocessor scheduling one run queue per processor –tasks tend to stay on a processor –advantage: processor cache scheduler performs dynamic load balancing –attempts to migrate only cache-cold tasks

35 COP 5994 - Operating Systems35 Linux Real-time Scheduling Soft real-time scheduler scheduling classes –SCHED_FIFO FIFO real-time tasks –SCHED_RR RR real-time tasks –SCHED_OTHER as before, non real-time tasks

36 COP 5994 - Operating Systems36 Windows XP Thread Scheduling thread dispatcher is part of micro kernel 32 Priority levels –0 = lowest priority –31 = highest priority –16 to 31: real-time threads –0: zero-page thread for idle-time tasks 32 ready queues RR for highest-priority ready queue

37 COP 5994 - Operating Systems37 Windows XP Priorities priority class + priority level = thread priority class level

38 COP 5994 - Operating Systems38 Thread Priority changes –Only for dynamic threads (1-15) –Priority boosts: Exiting the wait state Window receives user input Has not executed for a long time –Priority reduction Cannot go below base priority Reduced by one if thread executes for entire quantum Priority returns to previous level after one quantum if thread boosted because had not executed for a long time

39 COP 5994 - Operating Systems39 Windows XP Multiprocessor Scheduling Dispatcher considers: –affinity mask processors which may run thread less important for SMP –last processor processor on which thread executed last time it ran attempt to preserve processor cache –ideal processor Maximize parallelism –related threads, different ideal processors

40 COP 5994 - Operating Systems40 Agenda for next week: Chapter 9 –Memory management Read ahead !


Download ppt "Operating Systems Unit 5: – Processor scheduling – Java – Linux – Windows XP Operating Systems."

Similar presentations


Ads by Google