Fork Problem (revision 150921-r01)

Return to Lab 03

  1. Download today's task with command:
    $ wget --no-check-certificate
  2. Unzip the zip file. There should be 4 c files inside.
  3. Delete the zip file.
  4. Edit all documents:

    Please change [KELAS] with your class and [NPM] with your student ID. For example, ZCZC REG 1202000818.
  5. Study all .c sources.
  6. Compile all sources and give the executables the same name with the .c file (ex: fork01.c becomes fork01).
  7. Make "catat-Lab03.txt" with content:

    Change [KELAS] with your class, [DATE] with today's date (dd-mm-yyyy), [NPM] with your student ID, [REMARKS] with your short explanation, for example "This is too easy.".
  8. Capture the output in the screen while do fork's tutorial with command:
    $ script -a catat-Lab03.txt
  9. Execute all programs one by one.
    $ ./fork01
    $ ./fork02
    $ ./fork03
    $ ./fork04

    fork04 will not give any output simply because there are nothing to print on the code yet.
  10. Make a process tree as follows by modifying "fork04.c".

    The process sequence must be: P1,P2,P3,P4,P5,P6
  11. 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

    1. 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.
    2. Download Fork_B210 and use as source for complete the task.
    3. Use sleep() to manage the output.
  12. Compile again "fork04.c"
  13. Execute "fork04" program and put the output into fork04.txt
    $ ./fork04 > fork04.txt
  14. After all programs are executed, please stop the "script" program with command:
    $ exit
  15. This is the end of Fork Problem.

Return to Lab 03
Return to Wiki (2.13 KB) Ramot Stephanus Sihombing rast20, 21/09/2015 23:25

fork04-tree.png (87.6 KB) Ramot Stephanus Sihombing rast20, 21/09/2015 23:25