resources, accessing I/O... would you ! ! user process executing calls system call return from system call
On Interrupts On Interrupts
1. Driver tells disk controller 1. Driver tells disk controller 3. Interrupt controller asserts
what to do by writing into what to do by writing into pin on CPU to signal interrupt
device registers device registers
2. When it’s done, uses bus lines 2. When it’s done, uses bus lines
to signal interrupt controller to signal interrupt controller
chip chip
Disk Disk
drive drive
Disk
drive
OS restores state of the user 5
program (if applicable) or some 4
other user program
3 Linux
OS executes an RTI instruction
Interrupt Disk interrupt handling
to return to the user program
CPU Controller Controller
2
data structures
User program continues where 1
it was interrupted.
0
Key Fact: None of this is visible to
the user program
API
Everything
File Memory Manager Process Manager Boot & Network
System Init Support
Device Interrupt
Extensions & Add’l devices Drivers handlers Protection
Hardware Hardware
Advantages? !! ! ! Disadvantages?
Microkernels
Layered OS
(e.g. Mach, Chorus)
Users programs Minimize kernel services,
Each system service is a (see virtual I/O drivers) implement remaining OS
Client (user) programs
I run ls, you run ls - same program- but OS must track program counter
different processes A process has a stack
Less to a process than a program OS must track stack pointer
A program can invoke many processes to get OS stores state of processes’ computation in a
the job done (e.g. cc starts up cpp, cc1, process control block (PCB)
cc2, as–each a different process (and Data (program instructions, stack & heap)
program!)) resides in memory, metadata is in PCB
Anatomy of a Process Running a program
mapped segments
A program consists of Program starts running
Process’s DLL’s
Header code and data at _start()
address space Stack _start(args) {
Code On running a program, ! ret = main(args);
the loader: ! exit(ret)
Process Control }
Initialized data reads & interprets
Block executable
sets up the process’s When main() returns,
PC
Heap memory to contain the OS calls “exit()” which
Stack Pointer code & data from
executable
destroys the process
Registers
PID
Initialized data pushes “argc”, “argv” on and returns all its
UID the stack resources
Priority Code sets the CPU registers
properly & calls “__start()”
Executable File List of open files
…
Ready
Process Life Cycle Process Life Cycle
Processes are always either executing, waiting to Processes are always either executing, waiting to
execute or waiting for an event to occur execute or waiting for an event to occur
Waiting
Process Life Cycle Process Life Cycle
Processes are always either executing, waiting to Processes are always either executing, waiting to
execute or waiting for an event to occur execute or waiting for an event to occur
Waiting Waiting
Waiting Waiting
Process Life Cycle Process Life Cycle
Processes are always either executing, waiting to Processes are always either executing, waiting to
execute or waiting for an event to occur execute or waiting for an event to occur
Waiting Waiting
What happens on a
read()?
Start Done
Ready Running
Waiting
Much more than documents.
Discover everything Scribd has to offer, including books and audiobooks from major publishers.
Cancel anytime.