1.Process
Definition: the instance of a program (just like object is an instance of a object-oriented program)
What it has: machine instructions, registers, stack, heap
Process control block: PCB stores information like process's memory address, executable image resides on disk, privileges, and so forth
2.Dual Mode Operation
Dual-Mode: User mode and Kernel Mode
How to distinguish: A single bit in the processor status register
What Hardware support: (1)Privileged instructions (2) Memory Protection (3)Timer Interrupts
(1) Privileged instructions
Definition: Instructions that are available in kernel mode but not in user mode
What kernel dose: 1)change instructions' privilege levels, 2)adjust memory access, 3)disable or enable interrupts
What cause processor exception: Applications attempt to change it's privilege level or access restricted memory
(2) Memory Protection
How to perform Memory Protection: set memory Base and Bound for each process, and User-level code cannot change them. Every time processor fetches an instruct of the process, check its memory-access address with the base and bound.
Important features: 1) Expandable heap and stack 2)Memory sharing 3)Physical memory addresses 4) Memory fragmentation
virtual addresses: Every process start at virtual addresses, and hardware translate the virtual addresses into physical addresses with a map, operating system is responsible for maintaining the map.
Address randomization: Some OS randomizes the processes' virtual addresses each time they run to combat the virus.
(3)Timer Interrupt
What for: OS need to regain control of the processor from time to time, or some process (like dead loop) take up the whole processor and the OS crashes.
How to do: Hardware timer is set to interrupt the processor after a specified delay. When the timer interrupt occurs, the hardware transfer the user process to the kernel running in kernel mode.
3.Types of Mode Transfer:
User mode to Kernel mode:
(1) interrupt (2) processor exception (3) system call
Kernel mode to User mode:
(1) New process (2) back from interrupt or system call (3) switch to different process (4)User-level upcall
网友评论