Fork Problem (revision 141007-r02KI)¶
Return to Lab 04
- Download today's task with command:
$ wget --no-check-certificate https://projects.ui.ac.id/attachments/download/7837/Lab04-SRC.tar.bz2
- Look for the compressed file content with command:
$ tar tjf Lab04-SRC.tar.bz2
- Extract the compressed file with command:
$ tar xjf Lab04-SRC.tar.bz2
- Delete Lab04-SRC.tar.bz2 with command:
$ rm Lab04-SRC.tar.bz2
- Please edit all documents with vi
ZCZC [TOKEN] [NPM]
Please change [TOKEN] with your token and NPM with your student ID. For example, ZCZC 0O9GAG 1202000818.
- Please study all .c documents.
- Please compile all documents and give the same name with the .c file (ex: fork01.c becomes fork01).
$ gcc -o fork01 fork01.c
$ gcc -o fork02 fork02.c
$ gcc -o fork03 fork03.c
$ gcc -o fork04 fork04.c
- Make "catat-Lab04.txt" with content:
ZCZC [CLASS] TGS LAB04 [DATE]
ZCZC [TOKEN] LOG [REMARKS]
Change [CLASS] with your class, [DATE] with today's date (dd-mm-yyyy), [TOKEN] with your token, [REMARKS] with your short explanation, for example "I am confused.".
- Please capture the output in the screen while do fork's tutorial with command:
$ script -a catat-Lab04.txt
- Please execute all programs one by one.
fork04 will not give any output simply because there are nothing to print on the code yet.
- Please make a tree as follows by modified "fork04.c".
The process sequence must be: P1,P2,P3,P4,P5,P6
- The example of modified "fork04.c" is:
PID P1 (Induk Proses) = 5000
PID P2 = 5001 Lahir - PID Induk = 5000
PID P3 = 5002 Lahir - PID Induk = 5000
PID P4 = 5003 Lahir - PID Induk = 5002
PID P5 = 5004 Lahir - PID Induk = 5002
PID P6 = 5005 Lahir - PID Induk = 5003
- Download Fork_B210 and use as source for complete the task.
- Use sleep() to manage the output.
- Compile again "fork04.c"
- Execute "fork04" program and put the output into fork04.txt
$ ./fork04 > fork04.txt
- After all programs are executed, please stop the "script" program with command:
- This is the end of Fork Problem.
Return to Lab 04
Return to Wiki