Operating System Theory1
Operating System Theory1
• Most recently used instructions and data are in CPU caches for faster
access
So, what does
the OS do?
• OS manages program
memory – Loads program
executable (code, data)
from disk to memory
• OS manages CPU –
Initializes program counter
(PC) and other registers to
begin execution
• OS manages external
devices – Read/write files
from disk.
OS manages
CPU
• OS provides the process
abstraction – Process: a
running program – OS
creates and manages
processes
• Each process has the
illusion of having the complete
CPU, i.e., OS virtualizes CPU
• Timeshares CPU between
processes
• Enables coordination
between processes
OS manages
memory
• OS manages the memory
of the process: code, data,
stack, heap etc.
• Each process thinks it has a
dedicated memory space for
itself, numbers code and data
starting from 0 (virtual
addresses)
• OS abstracts out the details
of the actual placement in
memory, translates from
virtual addresses to actual
physical addresses
OS manages devices
• OS has code to manage disk, network
card, and other external devices: device
drivers.
• Device driver talks the language of the
hardware devices – Issues instructions to
devices (fetch data from a file) –
Responds to interrupt events from devices
(user has pressed a key on keyboard).
• Persistent data organized as a file
system on disk.
Design goals of an operating system
exit
Ready
Running
I/O event Interrupt
compilation
Process state
Process control Block
Each process is represented in OS by process control block (PCB)
Pointer Process
state
Process number
Program counter
Register
Memory limit
.
.
Idle
Fork a child
Child execute
End
CPU
Ready queue
I/O waiting
I/O queue