
Status ! Next project (after exam) – will be similar to last year BUT using a different strategy – perhaps stride scheduling. CSCI [4|6] 730 ! Scheduling ( 2-3 lectures, 2 before the exam – 3rd lecture (if needed) will not on the exam) Operating Systems ! Exam 1 coming up – Thursday Oct 6 » OS Fundamentals & Historical Perspective CPU Scheduling » OS Structures (Micro/Mono/Layers/Virtual Machines) » Processes/Threads (IPC,/ RPC, local & remote) » Scheduling (material/concepts covered in 2 lectures, Tu, Th) » ALL Summaries (all – form a group to review) 30% » What you read part of HW » Movie 2 Maria Hybinette, UGA Maria Hybinette,» UGA MINIX structure Scheduling Plans CPU Scheduling Questions? ! Why is scheduling needed? ! Introductory Concepts ! What is preemptive scheduling? ! Embellish on the introductory concepts ! What are scheduling criteria? ! Case studies, real time scheduling. ! What are disadvantages and advantages of different scheduling policies, including: » Practical system have some theory, and lots of tweaking (hacking). » Fundamental Principles: – First-come-first-serve? – Shortest job first? – Preemptive scheduling? » Practical Scheduling: – Hybrid schemes (Multilevel feedback scheduling?) that includes hybrids of SJF, FIFO, Fair Schedulers ! How are scheduling policies evaluated? 3 4 Maria Hybinette, UGA Maria Hybinette, UGA Why Schedule? What is the Point? Management Resources Can Scheduling make a difference? ! Resource: Anything that can be used by only a Process A single [set] process(es) at any instant in time Process B » Not just the CPU? I/O ! Hardware device or a piece of information CPU » Examples: No Schedule I/O Device – CPU (time), CPU – Tape drive, Disk space, Memory (spatial) A Schedule I/O Device – Locked record in a database (information, synchronization) ! Focus today managing the CPU Time ! No Schedule vs A Schedule ! Schedule another waiting process while current CPU relinquish to CPU due to I/O. 5 6 Maria Hybinette, UGA Maria Hybinette, UGA Resource Classification “Resource” Classification ! Pre-emptable ! Preemptable (forcible removable) » Can forcibly removed the resource from a process » Characteristics (desirable): (and possibly return it later) without ill effects. – small state (so that it is not costly too preempt it). – only one resource ! Non-preemptable » Examples: » Cannot take a resource away from its current ‘owner’ – CPU or Memory are typically a preemptable resources without causing the computation to fail. ! Non-preemptable (not forcible removable) » Characteristics: – Complicated state – May need many instances of this resource » Examples: – CD recorder - once starting to burn a CD needs to record to completion otherwise the end up with a garbled CD. 7 – Blocks on disk 8 Maria Hybinette, UGA Maria Hybinette, UGA Resources Management Tasks The CPU Management Team ! Allocation (Space): ! (how?)“The Dispatcher” (low level mechanism – the worker) » Space Sharing: Which process gets which resource » Context Switch (control access to resource)? – Save execution of old process in PCB – Add PCB to appropriate queue (ready or blocked) ! Scheduling (Time): – Load state of next process from PCB to registers » Time Sharing: In which order should requests be – Switch from kernel to user mode serviced; Which process gets resource and at what – Jump to instruction in user process time (order and time)? ! (when?) “The Scheduler” (higher level mechanism - upper management,) (time) Time and » Policy to determine when a specific process gets the CPU Space ! (where?) Sometimes also “The Allocator” (space) » Policy to determine which processes compete for which CPU » Needed for multiprocessor, parallel, and distributed systems 9 10 Maria Hybinette, UGA Maria Hybinette, UGA Dispatch Mechanism Entering System Mode Dispatcher is the module that gives control of the CPU to Same as - How does OS (scheduler) get control? the process selected by the scheduler. ! Synchronous interrupts, or traps » Event internal to a process that gives control to OS ! OS runs dispatch loop: » Examples: System calls, page faults (access page not in main while( forever ) memory), or errors (illegal instruction or divide by zero) { ! Asynchronous interrupts run process A for some time slice stop process A and save its context » Events external to a process, generated by hardware load context of another process B » Examples: Characters typed, or completion of a disk transfer jump to proper location and restart program } How are interrupts handled? ! Each type of interrupt has corresponding routine (handler or interrupt service routine (ISR) ! How does the dispatcher gain control? ! Hardware saves current process and passes control to ISR 11 12 Maria Hybinette, UGA Maria Hybinette, UGA How does the dispatcher run? How does dispatcher run? Option 1: Cooperative Multi-tasking Option 2: (external stimulus) True Multi-tasking ! (internal events) Trust process to relinquish CPU ! Guarantee OS can obtain control periodically through traps ! Enter OS by enabling periodic alarm clock » Trap: Event internal to process that gives control to OS » Hardware generates timer interrupt (CPU or separate chip) » Examples: System call, an explicit yield, page fault » Example: Every 10 ms (access page not in main memory), or error (illegal instruction or divide by zero) ! User must not be able to mask timer interrupt ! Disadvantages: Processes can misbehave ! Dispatcher counts interrupts between context switches » By avoiding all traps and performing no I/O, can take over » Example: Waiting 20 timer ticks gives the process 200 ms time entire machine slice » Only solution: Reboot! » Common time slices range from 10 ms to 200 ms (Linux 2.6) ! Not performed in modern operating systems 13 14 Maria Hybinette, UGA Maria Hybinette, UGA Scheduler Types ! Non-preemptive scheduler (cooperative multi-tasking) » Process remains scheduled until voluntarily relinquishes CPU (yields) – Mac OS 9. » Scheduler may switch in two cases: – When process exits – When process blocks (e.g. on I/O) ! Preemptive scheduler (Most modern OS, including most UNIX variants) » Process may be ‘de-scheduled’ at any time » Additional cases: – Process creation (another process with higher process enters system) – When an I/O interrupt occurs – When a clock interrupt occurs 15 Maria Hybinette, UGA Maria Hybinette, UGA Scheduling Goals: System View: Performance Metrics Threshold - Overall Efficiency ! There is a tension between maximizing: ! System Load (uptime): » The amount of work the system is doing » System’s point of view: Overall efficiency (favoring the whole, the forest, the whole system). ! Throughput: » Want many jobs to complete per unit time » User’s point of view: Giving good service to individual processes (favoring the ‘individuals’, the ! System Utilization: Throughput trees). » Keep expensive devices busy » Jobs arrive infrequently and both throughput and system utilization is low Satisfy both : fast process response time Offered Load (low latency) and high process throughput. ! Example: Lightly loaded system - jobs arrive infrequently - both throughput and system utilization is low. ! Scheduling Goal: Ensure that throughput increase linearly with load 17 18 Maria Hybinette, UGA Maria Hybinette, UGA User View: Good Service Utilization / Throughput (often measured as an average) ! Problem type: Job 1 Job 2 Job 3 » 3 jobs: 0 4 8 12 ! Ensure that processes quickly start, run and completes. st ! (average) Turnaround time: The time between job arrival and – 1 job enters at time 0, job completion. – 2nd job at time 4, and ! (average) Response time: The length of time when the job – 3rd job at 8 second arrive and when if first start to produce output » e.g. interactive jobs, virtual reality (VR) games, click on mouse » Each job takes 2 seconds to process. see VR change » Each job is processed immediately – unless a job is on ! Waiting time: Time in ready queue - do not want to spend a lot the CPU, then it waits of time in the ready queue » Better ‘scheduling’ quality metric than turn-around time since ! Questions: scheduler does not have control over blocking time or time a » (1) What is the CPU utilization at time t = 12? process does actual computing. ! Fairness: all jobs get the same amount of CPU over time – Consider the CPU utilization from t =0 to t=12. ! Overhead: reduce number of context switches – Percentage used over a time period. ! Penalty Ratio: Elapsed time / Required Service time » (2) What is the I/O device utilization at time t = 12? (normalizes according to the ‘ideal’ service time) - next week 19 20 Maria Hybinette, UGA» (3) What is the throughput (jobs/sec) at time = 12 – (10) Maria Hybinette, UGA Which Criteria is Appropriate? Depends on Expectation of the System Gantt Chart (it has a name)! ! All Systems: » Fairness (give processes a fair shot to get the CPU). » Overall system utilization A B C D » Policy enforcement (priorities) 10 14.2 17.3 22 0 ! Batch Systems (not interactive) » Throughput Time » Turn-around time » CPU utilization ! Shows how jobs are scheduled over time on the ! Real-time system (real time constraints) CPU. » Meeting deadlines (avoid losing data) » Predictability - avoid quality degradation in multimedia systems. 21 22 Maria Hybinette, UGA Maria Hybinette, UGA A Simple Policy: First-Come- Evaluate: First-Come-First- First-Served (FCFC) Served (FCFS) A Simple Policy: FCFS ! The most basic scheduling policy is first- ! Idea: Maintain FIFO list of jobs as they arrive come-first-served, also called first-in-first-out The
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages10 Page
-
File Size-