• When executing in kernel mode, the operating system has unrestricted access to both kernel and user’s memory.
• The load instructions for the base and limit registers are privileged instructions.
<--DUAL MODE OPERATION -->
• Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.
• Provides hardware support to differentiate between at least two modes of operations.
1. User mode – execution done on behalf of a user.
2. Kernel mode (also monitor mode, supervisor mode or system mode) – execution done on behalf of operating system.
• Mode bit added to computer hardware to indicate the current mode: kernel (0) or user (1).• When an interrupt or fault occurs hardware switches to kernel mode.
• Privileged instructions can be issued only in kernel mode.
<--I/O PROTECTION-->
• All I/O instructions are privileged instructions.
• Given the I/O instructions are privileged, how does the user program perform I/O?
• System call
– the method used by a process to request action by the operating system.
– Usually takes the form of a trap to a specific location in the interrupt vector.
– Control passes through the interrupt vector to a service routine in the OS, and the mode bit is set to kernel mode.
– The kernel verifies that the parameters are correct and legal, executes the request, and returns control to the instruction following the system call.
<--Use of a System Call to Perform an I/O-->
• Must ensure that a user program could never gain control of the computer in kernel mode. Otherwise, undesirable actions can be done e.g. a user program that, as part of its execution, stores a new address in the interrupt vector.
<--MEMORY PROTECTION-->
• Must provide memory protection at least for the interrupt vectorand the interrupt service routines.
• In order to have memory protection, add two registers that determine the range of legal addresses a program may access:
– Base Register – holds the smallest legal physical memory address.
– Limit Register – contains the size of the range
• Memory outside the defined range is protected.
<--CPU PROTECTION-->
• Timer
– interrupts computer after specified period to ensure operating system maintains control.
– Timer is decremented every clock tick.
– When timer reaches the value 0, an interrupt occurs.
• Timer commonly used to implement time sharing.
• Time also used to compute the current time.
• Load-timer is a privileged instruction.
0 comments:
Post a Comment