LAB #3 sleep/wakeup/wait/exit in MTX Kernel
ASSIGNMENTS
DUE & DEMO : to be posted
PRELIMINARY WORK: LAB2 MTX Kernel with [s|q|f] commands
Modify YOUR base MTX system in LAB #2 to include the following:
1. sleep(event)/wakeup(event):
As shown in Notes #4
2. pid = wait(&status):
The logic of wait() is explained in Notes #4.
Implement it in YOUR MTX.
3. RE-WRITE kexit() as follows:
A task calls kexit(int exitValue) to die, in which it
. (prompt for an exitValue, e.g. 0 to 9)
. print last gasp and records the exitValue in its proc.existValue;
. becomes a ZOMBIE;
. gives all children to Proc1;
. wakeup its parent;
. finally, tswitch() to give up CPU.
Thus, Proc1 cannot die if there are other existing procs
(Use nproc to keep track of the number of existing procs).
4. Add the follwoing commands FOR DEMO:
p : print the status of ALL procs:
pid ppid status=RUNNING|READY|SLEEP(event)|ZOMBIE|FREE
w : wait for a child proc to die:
1. error if no child;
2. print dead child pid and exitValue
5. ~samples/LAB3/mtximage.gz.bin
(download, mv to mtximage.gz, gunzip mtximage.gz,
dd to FD or use it as a virtual FD).