Provide hardware support to differentiate between at ° least two modes of operation: 1. User mode -- execution done on behalf of a user. 2. Monitor mode (supervisor/kernel/system mode) -- execution done on behalf of operating system.
Dual-mode operation(cont.) ° Mode bit added to computer hardware to indicate the current mode: monitor(0) or user(1). User ° When an interrupt or fault occurs, hardware switches to monitor mode. ° Privileged instructions only in monitor mode. Monitor Set user mode Interrupt/ fault
I/O Protection ° All I/O instructions are privileged instructions. ° Must ensure that a user program could never gain control of the computer in monitor mode, for 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 vector and the interrupt service routines. ° To provide memory protection, add two registers that determine the range of legal 0 256000 3000040 300040 Base register monitor Job1 0 addresses a program may address. ± Base Register - holds smallest legal physical memory address. ± Limit register - contains the size of the range. ° Memory outside the defined range is protected. 420940 880000 1024000 120900 Limit register Job 2 Job 4 Job 3
Hardware Address Protection
Protection Hardware (cont.) ° When executing in monitor mode, the OS has unrestricted access to both monitor and users’ memory. The load instructions for the base and limit registers ° are privileged instructions.
CPU Protection ° Timer - interrupts computer after specified period to ensure that OS maintains control. ± Timer is decremented every clock tick. ± When timer reaches a value of 0, an interrupt occurs. Timer is commonly used to implement time sharing. ° ° Timer is also used to compute the current time. ° Load timer is a privileged instruction.
General System Architecture ° Given the I/O instructions are privileged, how do users perform I/O? ° Via system calls - the method used by a process to request action by the operating system.
Operating System Structures ° Operating System Components ± Process Management, Memory Management, Secondary Storage Management, I/O System Management, File Management, Protection System, Networking, Command- Interpreter. ° Operating System Services, System calls, System Programs ° Virtual Machine Structure and Organization ° A Structural Approach to Operating Systems ° OS Design and Implementation
Operating System Services ° Services that provide user-interfaces to OS ° Program execution - load program into memory and run it ° I/O Operations - since users cannot execute I/O operations directly ° File System Manipulation - read, write, create, delete files ° Communications - interprocess and intersystem ° Error Detection - in hardware, I/O devices, user programs ° Services for providing efficient system operation ° Resource Allocation - for simultaneously executing jobs ° Accounting - for account billing and usage statistics ° Protection - ensure access to system resources is controlled
System Calls ° Interface between running program and the OS.
- One '20