Fork Problem (revision 160310-r01)¶
Return to Lab 04
- Download today's task with command:
$ wget --no-check-certificate https://projects.ui.ac.id/attachments/download/8334/Lab04-SRC.zip
- Unzip the zip file. There should be 4 c files inside.
- Delete the zip file.
- Edit all documents:
ZCZC [KELAS] [NPM]
Please change [KELAS] with your class and [NPM] with your student ID. For example, ZCZC REG 1202000818.
- Study all .c sources.
- Compile all sources and give the executables the same name with the .c file (ex: fork01.c becomes fork01).
- Capture the output in the screen while do fork's tutorial with command:
$ script -a WHAT-IS-THIS.txt
- Execute all programs one by one.
fork04 will not give any output simply because there are nothing to print on the code yet.
- Make a process tree as follows by modifying "fork04.c".
The process sequence must be: P1,P2,P3,P4,P5,P6
- The output 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
- The PID no (5000 etc) is just example, it will be different in your case since it depends on the number of processes run on your OS.
- 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