Lecture Operating systems: A concept-based approach (2/e): Chapter 4 - Dhananjay M. Dhamdhere

53 57 0
Lecture Operating systems: A concept-based approach (2/e): Chapter 4 - Dhananjay M. Dhamdhere

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 4 - Scheduling. Scheduling is the act of selecting the next process to be serviced by a CPU. This chapter discusses how a scheduler uses the fundamental techniques of prioritybased scheduling, reordering of requests, and variation of time slice to achieve a suitable combination of user service, efficient use of resources, and system performance. It describes different scheduling policies and their properties.

PROPRIETARYMATERIAL.â2007TheMcGrawưHillCompanies,Inc.Allrightsreserved.NopartofthisPowerPointslidemaybedisplayed,reproducedordistributed inanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,orusedbeyondthelimiteddistributiontoteachersandeducatorspermittedbyMcGrawưHill fortheirindividualcoursepreparation.IfyouareastudentusingthisPowerPointslide,youareusingitwithoutpermission. Chapter4:Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:1 Copyrightâ2008 Scheduling Scheduling is the act of determining the order in which requests should be taken up for servicing – A request is a unit of computational work * It could be a job, a process, or a subrequest made to a process Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 2 Copyright © 2008 Scheduling related concepts and terms • Request related concepts and terms – Arrival time * Request is submitted to the system – Admission time * Kernel starts considering the request for scheduling – Completion time – Deadline * Time by which servicing of a request should be completed – Service time * Total of CPU time and I/O time required to service a request – Preemption – Priority Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 3 Copyright © 2008 A schematic of scheduling    •  Admission of an arrived request may be delayed for reasons seen later •  An admitted request remains pending until it is scheduled •  A preempted request is put back into the pool of pending requests Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  SlideNo:4 Copyrightâ2008 Performance related concepts and terms User service related concepts and terms – Response time – Turn-around time – Weighted turn-around = Turn-around time / service time – Deadline overrun * Amount of time by which a deadline is missed – Fair share * A specified share of CPU time that should be devoted to a process or a group of processes – Response ratio * Response ratio = (time since arrival + service time) / service time Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 5 Copyright © 2008 Performance related concepts and terms • We shall use the following terms – Terms related to average service * Mean response time * Mean turn-around time – Terms related to scheduling performance * Schedule length  The total amount of time required to service a set of requests * Throughput  Number of requests serviced per unit of time Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 6 Copyright © 2008 Fundamental techniques of scheduling • Three fundamental techniques are used in scheduling – Priority-based scheduling * As seen in the context of multiprogramming – Reordering of requests: it may be used to * Enhance system throughput, e.g., as in multiprogramming * Enhance user service, e.g., as in time sharing – Variation of time slice * Small time slice yields better response times * Large time slice may reduce scheduling overhead Chapter 4: Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:7 Copyrightâ2008 More on priority Features of priority-based scheduling – Priorities may be static or dynamic * A static priority is assigned to a request before it is admitted * A dynamic priority is one that is varied during servicing of a request – How to handle processes having same priority? * Round-robin scheduling is performed within a priority level – Starvation of a low priority request may occur Q: How to avoid starvation? Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  SlideNo:8 Copyrightâ2008 Kinds of Scheduling Scheduling may be performed in two ways – Non-preemptive scheduling * A process runs to completion when scheduled – Preemptive scheduling * Kernel may preempt a process and schedule another one * A set of processes are serviced in an overlapped manner Q: What are the benefits of preemptive scheduling? Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 9 Copyrightâ2008 Processes for scheduling In our discussion, we will consider the following processes for scheduling Process Chapter 4: Scheduling P1 P2 P3 P4 P5 Arrival time Service time 3 Deadline 14 11 12 Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:10 Copyrightâ2008 Feasible schedule Feasible schedule – An application has a feasible schedule if there exists at least one sequence in which its processes can be scheduled that meets deadlines of all processes • Earliest deadline first (EDF) scheduling – Schedule the process with the earliest deadline Q: Justify the following statement: “If a feasible schedule exists for an application, then earliest deadline first (EDF) scheduling can meet all deadlines.” Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 39 Copyright © 2008 Operation of Earliest Deadline First (EDF) scheduling The notation Pi : n  is used to show that Pi  has the deadline n Chapter 4: Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:40 Copyrightâ2008 Rate Monotonic Scheduling (RMS) RMS is used for processes that run periodically – Rate of a process is the number of times it operates per second * A process is assigned a priority proportional to its rate * Priority-based scheduling is now used – Existence of a feasible schedule * If a process does not perform I/O  Share of CPU time used by it is = (service time / time period) * A feasible schedule exists if ∑processes (service time / time period) ≤ Q: Does RMS guarantee that deadlines will be met if a feasible schedule exists? Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 41 Copyright © 2008 Rate Monotonic Scheduling (RMS) • Consider three processes: Time period CPU time required P1 P2 P3 10 15 30 (CPU time required = service time if no I/O is performed) – What are their priorities? – Does a feasible schedule exist? * Feasible schedule exists if ∑ (CPU time required / time period ) ≤ – Schedule prepared by RMS is * P1, P2, P3 (2 seconds), P1, P3 (2 seconds), P2, P1, P3 (6 seconds) Chapter4:Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:42 Copyrightâ2008 Rate Monotonic Scheduling (RMS) Will RMS always find a feasible schedule? – Not guaranteed (consider P3 to have a time period of 27 sec) Time period CPU time required P1 P2 P3 10 15 27 – RMS will prepare an identical schedule (see previous slide) * P3 will miss its deadline by second Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 43 Copyright © 2008 Performance analysis • Performance is sensitive to the workload of requests directed at a server So it must be analyzed in the environment where the server is to be used – Three methods of performance analysis * Implement a scheduler, study its performance for real requests * Simulate the functioning of the scheduler and determine completion times, throughput, etc * Perform mathematical modeling using  Model of the server  Model of the workload to obtain expressions for service times, etc Chapter 4: Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:44 Copyrightâ2008 Mathematical modeling A mathematical model is a set of expressions for performance characteristics such as arrival times and service times of requests – Queuing theory is employed * To provide arrival and service patterns * Exponential distributions are used because of their memoryless property  Arrival times: F(t) =1 – e –αt, where α is the mean arrival rate  Service times: S(t) = – e –ωt, where ω is the mean execution rate * Mean queue length is given by Little’s formula  L = α x W, where L is the mean queue length and W is the mean wait time for a request Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 45 Copyright © 2008 Summary of performance analysis ρ = α/ω is the utilization factor of the server Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 46 Copyright © 2008 Scheduling in Unix • Process priorities are integer values – A larger value implies a lower priority – Priority of a process is varied based on its CPU usage Priority = Base priority + nice value + f(CPU time used by the process) Effect of CPU time decays with time, so only recent CPU usage affects priority Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 47 Copyright © 2008 Operation of a Unix-like scheduling policy when process perform I/O •  At time 1 second, P1’s T field contains 60 because it consumed 60 ticks •  Hence P1’s priority is computed as 60 (base priority) + 30 = 90 Q: How does this policy differ from round­robin time slicing policy? Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 48 Copyright © 2008 Fair-share scheduling using a Unix-like policy • Groups of processes are defined for ensuring fair share of CPU time – Priority of a process depends on the CPU time used by all processes in its group Priority of a process = Base priority + nice value + f(CPU time used by the process) + f(CPU time used by all processes in the same group) Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 49 Copyright © 2008 Operation of a fair share scheduling policy P1,P2,P3andP5formonegroup,P4formstheothergroup At2seconds,P2seffectivepriorityislowbecauseP1consumedsometime Chapter4:Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:50 Copyrightâ2008 Scheduling in Linux • Linux supports real time and non-real time applications – Real time processes * Have static priorities between (highest) and 100 (lowest) * Can be scheduled in FIFO or round-robin manner within each level – Non-real time process * Priorities: –20 to +19 * Priority is recomputed periodically according to nature of activity, and also to counter starvation • Each process has a time quantum (but it is called time slice in Linux) A high priority process has a higher quantum Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 51 Copyright © 2008 Scheduling in Linux • Two lists of processes are used: active list and exhausted list – The scheduler considers only processes in the active list – A process from active list is moved to exhausted list when its time slice is exhausted – When active list is empty, all processes are moved from the exhausted list to the active list – O(1) scheduling * Priority of a process is recomputed when its time slice expires, so overheads are spread uniformly Chapter4:Scheduling Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:52 Copyrightâ2008 Scheduling in Windows Real time threads have static priorities in range 16–31 Non-real time threads are in the variable priority class – They have priorities 1-15, computed from base priority of process, base priority of thread and a dynamic component – Priority is reduced by if the process uses up the time slice – When a thread blocked on an event wakes up, its priority is incremented depending on the event It is incremented by when it receives keyboard input – Priority is increased if a ready thread does not receive the CPU for seconds It is also given twice the normal burst Chapter 4: Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach, 2 ed  Slide No: 53 Copyright © 2008 ... ColumnCshowsthecompletiontimeofaprocess taistheturnưaroundtimeandwistheweightedturnưaround Chapter4 :Scheduling Dhamdhere: OperatingSystems AConceptưBasedApproach,2ed SlideNo:19 Copyrightâ2008 Variation of average response... ratio next (HRN) policy P14hasashorterservicetimethanP13 •  It has a higher response ratio at 8 seconds, so it is  scheduled ahead of P13 Qs:  Advantages / disadvantages over FCFS and SRN? Chapter 4:  Scheduling... it is swapped-in Chapter 4:  Scheduling Dhamdhere: Operating Systems— A Concept­Based Approach,  2 ed  Slide No: 27 Copyright © 2008 Ready lists in a time sharing system (a)    Initial state of the system

Ngày đăng: 30/01/2020, 04:58

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan