Presentation is loading. Please wait.

Presentation is loading. Please wait.

Uniprocessor Scheduling

Similar presentations


Presentation on theme: "Uniprocessor Scheduling"— Presentation transcript:

1 Uniprocessor Scheduling
Chapter 9

2 Aim of Processor Scheduling
Aim: is to assign processes to be executed by the processor or processors over time to meet system objectives. System objectives: Low response time RT: Time elapse from the submission of a request to the beginning of the response. High Throughput Throughput: Number of processes completed per unit time Processor efficiency High processor utilization (min processor idle time)

3 Types of Scheduling Long-term scheduling Medium-term scheduling
The decision to add to the pool of processes to be executed. Medium-term scheduling The decision to add to the number of processes that are partially or fully in main memory. Short-term scheduling The decision as to which available process will be executed by the processor. I/O scheduling The decision as to which process’s pending I/O request shall be handled by an available I/O device.

4 Types of Processor Scheduling

5

6 Long-Term Scheduling Determines which programs are admitted to the system for processing Controls the degree of multiprogramming If more processes are admitted, smaller percentage of time each process is executed, i.e more processes are competing for the same amount of processor time.

7 Long-Term Scheduling…
The long term scheduler may limit the degree of multiprogramming to provide satisfactory service to the current set of processes. The decision as to which job to admit next can be on a simple first-come-first-serve basis or it can be a tool to manage system performance.

8 Long-Term Scheduling…
The criteria used may include priority, expected execution time, and I/O requirements. For interactive programs in a time sharing system, a process request can be generated by the act of user attempting to connect to the system.

9 Long-Term Scheduling…
OS will accept all authorized users until the system is saturated (used some predefined measure of saturation). At this point, a connection request is met with a message indicating that the system is full and the user should try again later.

10 Medium-Term Scheduling
Part of the swapping function Based on the need to manage the degree of multiprogramming Done by memory management software.

11 Short-Term Scheduling
Short term scheduler known as the dispatcher Executes most frequently and makes decision of which process to execute next. Short term scheduler is invoked when an event occurs that may lead to the suspension of the current process or preempt currently running process in favor of another.

12 Short-Term Scheduling…
Examples of such event: Clock interrupts I/O interrupts Operating system calls Signals

13 Scheduling Algorithms
Topic covered: Short-Term Scheduling Criteria The Use of Priorities Alternative Scheduling Policies

14 Short-Tem Scheduling Criteria
Main objective  to allocate processor time to optimize one or more aspect on system behavior. A set of criteria is established against which various scheduling policies may be evaluated. The criteria can be categorized along two dimensions: User-oriented and System-oriented. Performance related and Not performance related.

15 Short-Tem Scheduling Criteria
User-oriented Relate to the behavior of the system as perceived by individual user or process Examples: Response Time in an interactive system RT: Elapsed time between the submission of a request until the response begins to appear as output. Scheduling policy must provide a good service to the various users. For RT, a threshold maybe define e.g. 2 seconds, then the goal of the scheduling mechanism should be to maximize the number of users who experience and average response time of 2 second or less.

16 Short-Tem Scheduling Criteria
System-oriented Effective and efficient utilization of the processor Example: Throughput Number of process completed per time.

17 Short-Term Scheduling Criteria
Performance-related Quantitative and generally can be measured Measurable such as response time and throughput Not performance related Qualitative and do not lend to themselves readily to measurement and analysis An example is predictability #Table 9.2 summarizes key scheduling criteria.

18 Priorities Implemented by having a multiple ready queues to represent each level of priority (Figure 9.4) Scheduler will always choose a process of higher priority over one of lower priority Lower-priority may suffer starvation Then allow a process to change its priority based on its age or execution history

19

20 Alternative Scheduling Algorithms
Table 9.3 summarize the information about the various scheduling algorithms. Selection function: determine which process among ready process (in Ready Queue) is selected for next execution. the function may be based on priority, resource requirements, or the execution characteristics of the process.

21 Alternative Scheduling Algorithms
Decision mode: Specifies the instant in time at which the selection function is exercised Two general categories: Nonpreemptive Once a process is in the running state, it will continue until (a) it terminates or (b) blocks itself for I/O or request OS services. Preemptive Currently running process may be interrupted and moved to the Ready state by the OS.

22 Scheduling Algorithms
Types of scheduling algorithms: First Come First Serve (FCFS) Shortest Process Next (SPN) Shortest Remaining Time (SRT) Round Robin Highest Response Ratio Next Feedback Draw the diagram Calculate the waiting time (WT) and average waiting time (AWT).

23 Process Scheduling Example
Arrival Time Service Time A 3 B 2 6 C 4 D 5 E 8

24 First-Come-First-Served (FCFS)
Each process arrive will join the Ready queue Selection Function: the process that has been waiting the longest in the ready queue, i.e the oldest process in the Ready queue is selected 5 10 15 20 A B C D E

25 First-Come-First-Served (FCFS)
Decision Mode: Non-preemptive A short process may have to wait a very long time before it can execute. A process that does not perform any I/O will monopolize the processor Favors CPU-bound processes I/O processes have to wait until CPU-bound process completes

26 First-Come-First-Served (FCFS)
Waiting time = start execution time – arrival time Process A  0 – 0 = 0 Process B  3 – 2 = 1 Process C  9 – 4 = 5 Process D  13 – 6 = 7 Process E  18 – 8 = 10 Average Waiting Time = Total waiting time Number of processes = = 4.6ms

27 Shortest Process Next Selection function: the process with the shortest expected CPU burst time. Decision Mode: Nonpreemptive 5 10 15 20 A B C D E

28 Shortest Process Next Process with shortest expected processing time is selected next Short process jumps ahead of longer processes Predictability of longer processes is reduced If estimated time for process not correct, the operating system may abort it Possibility of starvation for longer processes

29 Shortest Process Next Calculate the WT and AWT!!

30 Shortest Remaining Time
Selection function: the process with the shortest remaining time. Decision Mode: Preemptive version of shortest process next policy 5 10 15 20 A B C D E

31 Shortest Remaining Time
Higher overhead than SPN Must estimate processing time Small processes will run almost immediately but longer jobs have an even longer waiting time and variant of waiting time that in SPN.

32 Shortest Remaining Time
Calculate the WT and AWT!!

33 Round-Robin Selection function: same as FCFS Decision Mode: Preemptive
5 10 15 20 A B C D E Time quantum = 1 unit Selection function: same as FCFS Decision Mode: Preemptive Uses preemption based on a clock An amount of time is determined that allows each process to use the processor for that length of time

34 Round-Robin Clock interrupt is generated at periodic intervals
When an interrupt occurs, the currently running process is placed in the ready queue Next ready job is selected Known as time slicing

35 Round-Robin Calculate the WT and AWT!!

36 Highest Response Ratio Next (HRRN)
Selection Function: Choose next process with the highest ratio. Ratio = 5 10 15 20 A B C D E time spent waiting + expected service time expected service time

37 Highest Response Ratio Next (HRRN)
Decision mode: Non-Preemptive This approach is attractive because it accounts the age of the process. While shorter jobs are favored, aging without service increases the ratio so that a longer process will eventually get past competing shorter jobs. Expected service time must be estimated to use HRRN.

38 Highest Response Ratio Next (HRRN)
Calculate the WT and AWT!!

39 Feedback Decision mode: Preemptive (time quantum basis)
Used dynamic priority mechanism. 5 10 15 20 A B C D E Time quantum = 1 unit for all Ready Queue

40 Feedback When a process first enters the system, it is placed in RQ0 (Figure 9.4). After its first execution, when it returns to the Ready state, it is placed in RQ1. Each subsequent time that it is preempted, it demoted to the next lower-priority queue. Penalize jobs that have been running longer Don’t know remaining time process needs to execute

41 Feedback A shorter process will complete quickly, without migrating very far down the hierarchy process. A longer process will gradually drift downward. Newer shorter processes are favored over older, longer processes. Within each queue, except the lowest priority queue, a simple FCFS mechanism is used.

42 Feedback In lowest priority queue, a process cannot go lower, but it is returned to this queue repeatedly until it completes execution, it will treated in round robin fashion. Figure 9.10 illustrates the feedback scheduling mechanism by showing the path that a process will follow through the various queues

43

44 Feedback Calculate the WT and AWT!!

45 Scheduling Criteria Different scheduling algorithm have different properties and may favor one class of processes over another. Many criteria have been suggested for comparing Short-Term scheduling algorithms. The characteristics used for comparison can make substantial difference in the determination of the best algorithm.

46 Scheduling Criteria The criteria are:
CPU utilization – keep CPU as busy as possible. Throughput – number of processes that complete their execution per time unit. Turnaround time – amount of time to execute a particular process. Waiting time – amount of time a process has been waiting in the ready queue Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

47 Optimization Criteria
Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time


Download ppt "Uniprocessor Scheduling"

Similar presentations


Ads by Google