LAB Assignment #4
REQUIREMENTS
DUE & DEMO:
Modify the base MTX system 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. myexit(value) int value:
A task calls myexit(value) to die, in which it
. become a ZOMBIE;
. print last gasp and records the gasp string as "exitValue" in PROC;
. give away all children to Task1;
. wakeup its parent;
. finally, tswitch() to give up CPU.
Also, implement these into myexit():
Task1 cannot die if there are other READY tasks.
4. Add the follwoing commands FOR DEMO:
p : print the status of ALL tasks as
pid ppid status=runnikng|READY|SLEEP(event)|ZOMBIE|FREE
z : sleep(running->pid); sleeps on its own pid.
k : for i=1,2,..,NTASK: wakeup(i); try to wakeup ALL sleeping tasks.
w : pid=wait(&LastGasp); wait for a ZOMBIE child (free its PROC).
Print the dead child pid and its last gasp string.
5. LAB4/lab4.bin.gz is a sample solution.
t.c amd ts.x are sample code for Lab#4