6.033 Computer System Engineering

advertisement
MIT OpenCourseWare
http://ocw.mit.edu
6.033 Computer System Engineering
Spring 2009
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Enforcing Modularity
module per computer
module per virtual computer
VM
Virtual processor
Virtual Processor
Each program – “Thread” of execution
T1
Cooperative
vs
Preemptive
T2
proc
instructions,
registers, PC, SP
stack
Same AS
vs
Diff
Yield()
yield {
Save state
Schedule next thread
dispatch next thread
}
int table[NUM_THREADS]
int next
int me Å local to thread
Stack Example
yield
yield
1000
…….
SP
104
204
148
5
T2
…….
Thread
1
2
208
204
200
T1
T2: Net
1000
…….
SP *
T1: Halo
108
5
104
100
Stack
yield
1025
148
1025
Preemptive scheduling
(No explicit yield)
Timer interrupt
Processor line
checked by µProc before each instr
If high, calls “gate”
Kernel calls yield() on current thread
Save state
schedule + run next thread
Processes – AS + thread(s)
Kernel support
create
destroy
alloc AS, phys. mem, page map
load code into mem, map into AS
create thread, add to thread table
remove AS
remove thread from table
Layering of Threads
Halo
share
fate
AS
Emacs AS
enf
modularity
µProc
Parent threads
- Scheduling policy
- Switching mech.
Layering of Threads
Parent threads
- Scheduling policy
- Switching mech.
User
Halo
kernel
…
Emacs
main
interrupt
µProc
Coordinating Access
Sequence Coord
wait(v, cond)
signal(v)
Web Server
Net
Thread
Disk
Req Thread
while(true)
while(empty());
m = dequeue()
process(m)
while(true)
m = next_blk()
while(full()){};
enqueue(m)
Download