* cormen book
[mascara-docs.git] / i86 / mtx-16-bit / docs / 09-sleep-wait-exit-in-kernel.txt
blob8d306966dfa8c1aec333c534a650ea63ddb0b979
1 LAB #3 sleep/wakeup/wait/exit in MTX Kernel
3                         ASSIGNMENTS
5                DUE & DEMO : to be posted
7 PRELIMINARY WORK: LAB2 MTX Kernel with [s|q|f] commands
9 Modify YOUR base MTX system in LAB #2 to include the following:
11 1. sleep(event)/wakeup(event):
12    As shown in Notes #4
14 2. pid = wait(&status):
15    The logic of wait() is explained in Notes #4.
16    Implement it in YOUR MTX.
18 3. RE-WRITE kexit() as follows:
19    A task calls kexit(int exitValue) to die, in which it
20      . (prompt for an exitValue, e.g. 0 to 9)
21      . print last gasp and records the exitValue in its proc.existValue;
23      . becomes a ZOMBIE;
24      . gives all children to Proc1;
25      . wakeup its parent;
26      . finally, tswitch() to give up CPU.
28    Thus, Proc1 cannot die if there are other existing procs
29         (Use nproc to keep track of the number of existing procs).
31 4. Add the follwoing commands FOR DEMO:
33     p  : print the status of ALL procs:
35            pid ppid status=RUNNING|READY|SLEEP(event)|ZOMBIE|FREE
37     w  : wait for a child proc to die:
38               1. error if no child;
39               2. print dead child pid and exitValue
41 5. ~samples/LAB3/mtximage.gz.bin
42    (download, mv to mtximage.gz, gunzip mtximage.gz,
43     dd to FD or use it as a virtual FD).