Modern operating systems are interrupt driven, meaning that if there are no processes to execute, no I/O devices to service, and no users to whom to respond, an operating system will sit quietly waiting for something to happen. An interrupt service routine is provided to deal with the interrupt.
To ensure that an error in a user program could cause problems only for the one program running, a properly designed operating system must ensure that an incorrect (or malicious) program cannot cause other programs to execute incorrectly. This is done by creating an interrupt service routine to deal with each type of interrupt.
Dual-Mode and Multi-mode Operation
Computer systems provide hardware support to differentiate between operating-system code and user-defined code to ensure proper execution of the operating system.
The mode bit is added to the hardware of the computer to indicate the current mode: user mode or kernel mode. This allows the system to distinguish between tasks that are executed on behalf of the operating system and those that are executed on behalf of the user. This architectural enhancement is useful for many other aspects of system operation.
At system boot time, the hardware starts in kernel mode and the operating system starts user applications in user mode. Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel mode. This dual mode of operation protects the operating system from errant users by designating some machine instructions as privileged instructions and allowing them to be executed only in kernel mode. If an attempt is made to execute a privileged instruction in user mode, the hardware treats it as illegal and traps it to the operating system.
The instruction to switch to kernel mode is an example of a privileged instruction. Some other examples include I/O control, timer management, and interrupt management. As we shall see throughout the text, there are many additional privileged instructions.
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.