@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 twmodes 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 currenmode: 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 OPERATION
• All I/O instructions are privileged instructions.
• 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.
• 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 vectoand 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 memoryaddress.
– 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