Operating System Fundamentals


Figure 3.3 A sample process table



Download 2.34 Mb.
View original pdf
Page20/66
Date06.03.2023
Size2.34 Mb.
#60834
1   ...   16   17   18   19   20   21   22   23   ...   66
OperatingSystemFundamentals
best answers from c, Lesson 2 C# Windows Forms
Figure 3.3
A sample process table
At no time would it be possible to have two processes both with the state ‗Running‘ as we are assuming for now that the CPU has only a single core.
Processor Preservation
An important concept in operating system design is the ability to hide multitasking concepts from the applications so that they do not know that other applications are running at the same time and sharing the CPU. The registers in the CPU become a resource that is shared by every process on the operating system, including the operating system itself. Keeping these values correct is critical to making an operating system that functions correctly. As an example if one application performs the instruction ―mov $50, %eax‖ it means that the program expects the value 50 to be placed into the EAX register. If this instruction were executed then another process ran that put the value 0 into the EAX register, the old value of 50 needs to be replaced before the first process runs again. Each process on the system requires a place where the registers can be stored while the process is not running. The operating system can either put this information directly into the process table or it can store the information somewhere else but keep a pointer to the information in the process table. State Changing Changing the state of a process from one state to another is usually the responsibility of the operating system. The actual switch could occur because the process has informed the operating system that it is finished, or the operating system could determine that the process has simply used too much time and it is another process turn to run. Of course, the operating system itself is software that must run on the CPU along with the applications. So how does the application actually become active so that it can stop Word in the example above Many hardware platforms include a clock that periodically fires interrupts and the operating system has likely attached a function called a scheduler to the interrupt so that every so many milliseconds (atypical number isms) the operating system scheduler gets executed. When the scheduler is called (by the interrupt) the scheduler code can manipulate the process table and set the state of the processes involved and then allow the new process to takeover.

Operating System Fundamentals
29 As an example suppose that the process table looks like the example above with the four processes and Word.exe executing. Here is the order in which things happen.
1. The word process is executing normally using the CPU registers as it requires.
2. The clock triggers an interrupt.
3. The interrupt service routine attached to the clock runs the OS scheduler.
4. The scheduler searches the process table for the process in the Running state.
5. The scheduler changes the state of the running process to ready.
6. The scheduler copies all of the current value of the registers into the process table (or information block)
7. The scheduler looks in the table to find the next process to run. The topic of selecting a process to run is covered in the next chapter but for here lets assume that iexplorer is about to run.
8. The scheduler marks iexplorer as Running
9. The scheduler copies all of the registers for iexplorer into the CPU from the process table. The scheduler then jumps to the next instruction that iexplorer should perform.

Download 2.34 Mb.

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




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

    Main page