Operating System Fundamentals


Preemptive and Non-preemptive Switching



Download 2.34 Mb.
View original pdf
Page21/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   17   18   19   20   21   22   23   24   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Preemptive and Non-preemptive Switching
The steps above describe a type of process switching known as preemptive switching. The operating system always has control of the computer byway of the interrupt service routine and will always be able to stop the currently executing process. Ina non-preemptive operating system, the operating system never interrupts the currently executing process but waits for the process to release control voluntarily. In such a system, the operating system is generally less complex. However, if a process does not wish to cooperate with the other processes on the computer then this could lead to other processes, including some operating system parts, never having a chance to execute. The most recent popular non-preemptive operating system was Windows 3.1. In this operating system, a programmer who accidentally created certain types of infinite loops would often have to reboot their computer in order to stop their program. As a result, most operating systems today utilize preemptive process switching so that no single process can monopolize the computer.
Blocking
Generally the CPU executes instructions very quickly and transferring data to and from RAM also takes place with very little delay. Unfortunately, if a process wishes to interact with some external device the CPU cannot do very much useful work. As an example, suppose we have written a very simple program that does nothing until the user presses a key on the keyboard. The computer instructions may look something like this

Operating System Fundamentals
30 Main) {
System.in.read(value);
} When this process is started, there will be some instructions required to get the application ready, but eventually the instruction wait for key is reached. When the process reaches this instruction what does the operating system do with the process state In our two state process model introduced earlier (see Figure 3.2), leaving the process as Running is probably not a good idea because it really is not doing anything. Moving the process to the Ready state does not help either because the process is not actually ready to run. It needs to wait for the user to do something. We solve this problem by the introduction of a third state that we will call ‗Blocked‘. This state tells the operating system that the process is currently waiting for something, and therefore it should never be considered by the scheduler when anew process is being selected for running. The term blocked exists because the execution is being blocked by some external event. Some operating systems might use the term wait. Running dispatched interrupted
Ready
Blocked wait
Event complete

Download 2.34 Mb.

Share with your friends:
1   ...   17   18   19   20   21   22   23   24   ...   66




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

    Main page