Fork Problem (revision 141007-r02KI)

Return to Lab 04

  1. Download today's task with command:
    $ wget --no-check-certificate
  2. Look for the compressed file content with command:
    $ tar tjf Lab04-SRC.tar.bz2
  3. Extract the compressed file with command:
    $ tar xjf Lab04-SRC.tar.bz2
  4. Delete Lab04-SRC.tar.bz2 with command:
    $ rm Lab04-SRC.tar.bz2
  5. Please edit all documents with vi

    Please change [TOKEN] with your token and NPM with your student ID. For example, ZCZC 0O9GAG 1202000818.
  6. Please study all .c documents.
  7. 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
  8. Make "catat-Lab04.txt" with content:

    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.".
  9. Please capture the output in the screen while do fork's tutorial with command:
    $ script -a catat-Lab04.txt
  10. Please 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.
  11. Please make a tree as follows by modified "fork04.c".

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

Return to Lab 04
Return to Wiki