Dual-mode Protection
202310061634
Status: #idea
Tags: OS
Dual-mode Protection
flowchart TD 0[Dual-mode protection] --- 1[User mode] 0 --- 2[System/monitor mode]
- Hardware has 1 bit for the 2 modes
- User mode - System mode (monitor mode)
- Switch to monitor mode if:
- Interrupt is raised
- Fault occurs
- Privileged instructions need to be run
- Kernel needs to perform some work
Info
A system call changes to kernel mode, and after executing, returns to user mode
Note
Now, CPUs support multi-mode operations (like Virtual Memory Manager for VMs)
CPU Protection
- OS sets a timer to prevent infinite loops
- Updated with the help of a physical clock
- Used to calculate running time
- Setting the timer is a privileged operation
I/O Protection
- All I/O instructions are privileged
- Must ensure that the user program does not control the computer in monitor mode
Memory Protection
flowchart LR 0[Logical address] -->|"Memory management\nunit (MMU)"| 2[Physical address]
- Needed for IVT and ISR (interrupt service routine)
- Determine the range of legal addresses a program may access
- Base register: Holds smallest legal memory address
- Limit register: Contains size of the range
- Memory outside said range is protected