Virtualization
Build an illusion (as many CPU & RAM as you want)
Goals
- Efficiency
- Security
- Isolation
Abstraction
What changes when a program runs?
- registers
- memory
- I/O
CPU: How to Virtualize
- Run
proceses “at once” even though we have CPUs - General idea:
- If 1 CPU, 2 processes (A, B)
- Run as ABABABAB… (interleave) aka “time sharing”
- Mechanisms: low-level how
- Policies: whilch process to run?
First Attempt: Direct Execution
Boottime: (Start up)
OS is the first program to run
- Set up:
- free list (to track memory)
- process list (etc.)
Want: Run One Program
- alloc entry on process list
- alloc some memory
- load the program (from disk) into memory (code, static)
- jump to
main
of the prgram & start running
Obersavation
- Only one thing running at at time
Problems
- What if process
wants to do something restricted? (e.g., issue a read to disk)
Hardware Support- Modes of Opertaion - User mode / Kernel mode
- Bit: 0 or 1 => which modes
- Transition between modes
Instructions:- user mode -> kernel mode: trap
- kernel mode -> user mode: return-from-trap
- Set up trap handlers
- Modes of Opertaion - User mode / Kernel mode
- What if OS wants to stop
, and run ? - What if
does something that is “slow”? (I/O)
Timeline
- OS @ boot
Set up- trap handlers
- free list (to track memory)
- process list (etc.)
- Process @ run time
- issue system calls (func written in asm that calls
trap
)
- issue system calls (func written in asm that calls