Operating System Fundamentals


Priority-Based Scheduling



Download 2.34 Mb.
View original pdf
Page34/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   30   31   32   33   34   35   36   37   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Priority-Based Scheduling
The round-robin type scheduling appears to be a very fair algorithm, and inmost cases the use of this algorithm works well. However, there are some situations where another form of scheduling leads to abetter system from the users point of view. Most people have probably used a computer atone time when the computer did not seem to be responding. While using MS Word you may find yourself typing a few keys but nothing appears on the screen fora few seconds, then suddenly all of the characters you typed appear at the same time. Although it might be okay if this happens just once a month, it should not be happening every few minutes. While the user is typing they generally like to have some sort of instant feedback so they know their keys are being accepted. If it took five seconds for your phone to show the digit you pressed when dialing a number, you would find this quite unacceptable. Unfortunately, with round-robin scheduling instant feedback is not possible unless we choose a very small time slice and we do not have a lot of processes. While your computer (or mobile) is running another process, we need someway of having the user application interrupt other applications. In order to keep track of which processes are more important, the process table generally contains an entry called the
priority. Each time the scheduling algorithm is executed, the scheduler will look at the process table for the process that is in the Ready state and pick the process with the highest priority.
Figure 3.8
Windows Task Manager Showing Process
Priorities

Operating System Fundamentals
49 An operating system could allow the process itself to pick its own priority, or the priority could be picked by the operating system. In some operating systems, priorities are simply low, medium or high. In other operating systems, the priorities maybe arranged between 0 and 255 with 0 being the highest and 255 being the lowest (the meanings could be reversed with a larger number being higher in priority. What do we do if there are two processes with the same priority The usual implementation is to utilize round-robin scheduling for all processes that are of equal priority. When a process is put into the Run state, it will get to run until one of the following things happens
1. it finishes,
2. it blocks,
3. a higher priority process becomes ready. What if the process never blocks or finishes Then the process gets to monopolize the CPU and never allows any other process to run. When a process never gets to run because a high priority process is using all of the time, it is called starvation. Starvation is a danger of any operating system relying on priorities for scheduling and it requires careful programming to ensure that it does not happen. You maybe wondering how a higher priority process would ever become ready if another process is running all of the time. As long as the currently running process eventually waits or gives a semaphore that the higher priority process is waiting for, then the high priority process gets to run. Inmost operating systems, processes started by the user (application) are assigned the same priority, and generally the processes created by the operating system are provided a higher priority so that the developers do no need to worry about this aspect. In the Windows Task manager, it is possible to change the priority of the processes. Linux also allows for the user to lower the priority of a process.

Download 2.34 Mb.

Share with your friends:
1   ...   30   31   32   33   34   35   36   37   ...   66




The database is protected by copyright ©ininet.org 2024
send message

    Main page