Fork Problem (revision 160310-r01)

Return to Lab 04

  1. Download today's task with command:
    $ wget --no-check-certificate https://projects.ui.ac.id/attachments/download/8334/Lab04-SRC.zip
    
  2. Unzip the zip file. There should be 4 c files inside.
  3. Delete the zip file.
  4. Edit all documents:
    ZCZC [KELAS] [NPM]

    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. Capture the output in the screen while do fork's tutorial with command:
    $ script -a WHAT-IS-THIS.txt
    
  8. 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.
  9. Make a process tree as follows by modifying "fork04.c".

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

    HINT
    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.
  11. Compile again "fork04.c"
  12. Execute "fork04" program and put the output into fork04.txt
    $ ./fork04 > fork04.txt
    
  13. After all programs are executed, please stop the "script" program with command:
    $ exit
    
  14. This is the end of Fork Problem.

Return to Lab 04
Return to Wiki

Lab04-SRC.zip (2.13 KB) Ramot Stephanus Sihombing rast20, 10/03/2016 02:15