1 / 61

Processes and Scheduling Section III

Processes and Scheduling Section III. Objective of scheduling. Fairness----Prevent starvation Efficiency Throughput Response time. Types of scheduling (调度类型 p379 ). Sorted by OS types (按系统类型分类) Batch scheduling (批处理调度) Time-sharing scheduling ( 分时调度) Real-time scheduling (实时调度)

fern
Download Presentation

Processes and Scheduling Section III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Processes and SchedulingSection III

  2. Objective of scheduling • Fairness----Prevent starvation • Efficiency • Throughput • Response time

  3. Types of scheduling(调度类型p379) • Sorted by OS types(按系统类型分类) • Batch scheduling(批处理调度) • Time-sharing scheduling (分时调度) • Real-time scheduling (实时调度) • Multiprocessor scheduling(多处理机调度) • Sorted by perform frequency and scheduling unit(按执行频率分类) • Long-term scheduling(长程调度) • Medium-term scheduling (中程调度) • Short-term scheduling (短程调度) • I/O scheduling

  4. Scheduling and Process State Transitions (p380)

  5. Levels of Scheduling(分级调度图P381)

  6. P382

  7. Long-term scheduling(P380) • Determines(确定) which program are admitted to the system for processing. Controls the degree of multiprogramming(多道程度). Once admitted(提交), a job becomes a process and is added to the queue for short-term scheduler or for medium-term scheduler. • In a batch system, the long-term scheduler chooses the jobs held in(保持在) disk queue and creates processes from the queue when it can.

  8. Two problems for long-term scheduling(p381) • Decide the number of processes that OS can take on, which is decided by the degree of multiprogramming. • Which job or jobs to accept and turn into(转化为) processes. • Decided by scheduling algorithm,e.g. FCFS、SJF、HRRN etc… • When to invoke the long-term scheduler? • States of Job: admit, execution, finish

  9. Medium-term scheduling(p383) • Part of the swapping function(交换功能). Choose processes in disk to swap in for execution.

  10. Short-term scheduling(p383) • Known as the dispatcher(分派器), executes most frequently and makes the fine-grained(细粒度) decision of which process to execute next. • The event to invoked(引起) the short-term scheduling • Clock interrupts • I/O interrupts • Operating system calls • Signals (信号)

  11. Scheduling Criteria(准则) T9.2(p385) • User Oriented, Performance Related(面向用户,考虑性能) • Response time(响应时间). From the submission(提交) of a request until the response begins to be received. Often be used in time-shared time. • Turnaround(周转)time. The interval(间隙) of time between the submission of a process and its completion. Often be used in batch systems. • Deadlines(截止期). The deadlines be specified for a process, such as starting deadlines and completion deadlines.

  12. Scheduling Criteria (II) • System Oriented(面向系统) • Throughput(吞吐量). The number of processes completed per unit of time. Often used in batch system. • Processor Utilization(利用率). Percentage of time that the processor is busy. • Balancing(平衡)Resources. Used in long-term and middle-term scheduling. • Fairness(公平). No process should suffer starvation(受饥饿).

  13. Scheduling Criteria (III) • System Oriented • Enforcing priorities(优先权). The scheduling policy should favor higher priority processes. • Implement(实现): Multi-queue F9.4(P386) • To avoid starve, consider the waiting time as a faction(因素) to calculate priority.

  14. Multi-queue(多队列p386)

  15. Scheduling Algorithms(p388) • Selection function: • w: time spent waiting for the processor(从提交到现在的等待时间) • e: time spent in execution so far(到现在的执行时间) • s: total service time required by the process, include e(需要被服务的总时间)

  16. Scheduling Algorithms(p388) • Decision mode(调度模式) • Nonpreemptive(非抢占): Once a process is in the running state, it continues to execute until it terminates or blocks itself to wait for I/O or by requesting some OS service. Often used in batch system. • Preemptive(抢占): The running process may be interrupted to ready state. Often used in time-sharing or real-time system. • Preemptive policies incur(引入) greater overhead than nonpreemptive ones but provide better service.

  17. Examples (p388) • Five processes

  18. Analysis(p389~390) • Using six scheduling algorithms in the example, calculates the average turnaround(周转) time, and (Tq / Ts)(Fig 9.5 & Table 9.4).

  19. 5 0 10 15 20 First Come First Served(FCFS) 1 2 3 4 5

  20. FCFS(p389~391) • Simple to implement, but: • Inefficient for using resource. • Unfairness. Favor(有利于) for processor-bound(计算型) processes but not favor for I/O- bound processes.

  21. Unfairness of FCFS(p391)

  22. Application of FCFS(p391) • FCFS is not an attractive alternative(选择) on its own for a single-processor system. However, it is often combined with a priority scheme to provide an effective scheduler.

  23. 5 0 10 15 20 Round Robin(RR)(p391) 1 2 3 4 5

  24. RR • Time slice(时间片). If the quantum(数量) is very short, system overhead to finish process switch(进程切换) is high. To large, the user can not tolerate. • Disadvantage(缺点):A I/O-bound process only need little time, but it must wait a RR cycle. • Used in time-sharing system.

  25. Virtual Round Robin (VRRp393) • VRR:Add an auxiliary(辅助) queue to storage the I/O finished processes. It has higher priority than ready queue but it can get little slice than ready queue. (P393,Fig 9.7) • Analysis: VRR is fair than RR algorithm.

  26. 5 0 10 15 20 1 2 3 4 5 Shortest Process Next (SPN P395)

  27. SPN(P395) • Advantage • Reduces the average waiting time, improve the system performance and throughtput. • Disadvantage • Difficult to confirm(确定) the execution time of a process. • Unfair to long process. • Do not consider the pressure task and not suitable for time-sharing and transition process system.

  28. Confirm the Execution Time of a Process(p395)

  29. 5 0 10 15 20 1 2 3 4 5 Shortest Remaining Time (SRT)

  30. SRT(p397) • SPN + Preempt. • Difficult to confirm the remain execution time of a process and unfair to long process. • The average turnaround time(周转时间) is short than SPN. • Elapsed(已流逝的) service times must be recorded.

  31. 5 0 10 15 20 Highest Response Ratio(响应比) Next (HRRN) 1 2 3 4 5

  32. HRRN(p397) • Response ratio RR= (w + s)/ s=1+w/s • If two processes have same waiting time, then the process who requests short service time has a higher priority(SPN); • If two processes have same service time, then the process who waits for longer time has a higher priority(FCFS); • For a long process, it’s priority will increase going with the waiting time. • Difficult to confirm the execution time of a process. • Need to calculate the response ratio.

  33. 5 0 10 15 20 1 2 3 4 5 Feedback(反馈FB q=1)

  34. FB(p398) • Need not to confirm the services time of a process. • Multi ready-queue, every queue has a different priority. • The higher the priority of a queue, the shorter the time slice for that queue; • A new process first in the highest priority queue, and if it can not complete in the first queue,it will be put into the second queue… • Only the first queue is empty, the second queue can be scheduling and so on…

  35. FB F9.10,P398

  36. FB(p398) • Be favor for interaction job ( often short job) • Be favor for short batch job • Long process maybe starve if there are many new short processes come in. • The last queue is treated in RR algorithm.

  37. Real-Time Scheduling (p430)

  38. Real-Time System • Real-time system may be defined as that type of computing in which the correctness of the system depends not only on the logical result of the computation, but also on the time at which the results are produced.(实时任务运行结果的正确性依赖于时间和运行逻辑)

  39. Types of real-time task(p430) • Periodic and aperiodic task.(周期和非周期任务) • Sort by deadline(按截止时间分类) • Hard real-time task is one that must meet its deadline; otherwise it will cause undesirable damage or a fatal error to the system. • Soft real-time task has an associated deadline that is desirable but not mandatory(强制); it still makes sense to schedule and complete the task even if it has passed its deadline.

  40. Characteristics of Real-time OS(P430) • Determinism(确定性):Performs operations at fixed, predetermined times or within predetermined time intervals. • Responsiveness(响应性): How long, after acknowledgement, it takes an OS to service an interrupt. • User control:Is generally much broader(多) in a real-time OS than in ordinary OS. • Reliability(可靠性):Far more important for real-time OS than non-real-time systems. • Fail-soft operation(抗毁性):The ability of a system to fail in such a way as to preserve as much capability(能力) and data as possible.

  41. Features of real-time OS(p432) • Fast process or thread switch. • Small size (with minimal functionality). • Ability to respond to external interrupts quickly. • Multitasking with interprocess communication(进程间通信) tools such as semaphores, signals, and events. • Use of special sequential files that can accumulate data at a fast rate. • Preemptive scheduling based on priority. • Minimization of intervals during which interrupts are disabled.(最小化禁止中断的时隙) • Primitives to delay tasks for a fixed amount of time and to pause/resume tasks.(具有延迟、暂停、继续任务的原语) • Special alarms and timeouts.

  42. Analysis(p432) • Round Robin Preemptive Scheduler • A task must await its next time slice. Unacceptable for real-time applications.

  43. Priority-driven(优先权) Nonpreemptive Scheduler • A real-time task has high priority and would be scheduled as soon as the current process blocks to run to completion. This could lead to delay of several seconds. Not acceptable.

  44. Priority-driven Preemptive Scheduler • Combine priorities with clock-based interrupts. Preemption points(抢占点) occur at regular intervals(规则的间隙). Such a delay may be on the order of several milliseconds.

  45. Immediate Preemptive Scheduler • OS responds to an interrupt almost immediately, unless the system is in a critical-code lockout(停止) section. Scheduling delays for a task can then be reduced to 100μs or less.

  46. Types(类型) of Real-Time Scheduling • Static table-driven (静态表) approaches. • Static priority-driven (静态优先权) preemptive approaches. • Dynamic planning-based(动态规划) approaches. • Dynamic best effort(动态最大努力) approaches.

  47. Static Table-Driven Approaches(p434) • Is suitable to tasks that are periodic(周期). Input to the analysis consists of the periodic arrival time, execution time, periodic ending deadline, and relative priority of each task. Earliest-deadline-first (EDF)are typical of this category.

  48. Static Priority-Driven Preemptive Approaches • Priority assignment is related to the time constraints associated with each task. One example of this approach is rate monotonic(单调速率) algorithm, which assigns static priorities to tasks based on their periods.

  49. Dynamic Planning-Based Approaches • After a task arrives, but before its execution begins, an attempt is made to create a schedule that contains the previously scheduled tasks as well as the new arrival. (新任务到达要参与调度) • If the new arrival can be scheduled in such a way that its deadlines are satisfied and that no currently scheduled task misses a deadline, then the schedule is revised to accommodate the new task.(接纳新任务)

More Related