Lab07 Fork and Pipe (revision 130911-r02)

  1. Study the related functions [pipe(), fork(), close(), getpid(), write()] with linux manual. Manual (man) is not implemented in our Tiny Core, so you can find it in the Internet, for example in this site.
  2. PIPE: you can write from one end, and read it from the other end. WARNING: Too many writes with no reads may cause the PIPE overflow and crash.
  3. You can create a pipe in a process with system call pipe(), but it is less fun:
  4. A forked process and pipe (some fun). Whatever a process (parent or child) writes, can be read by both parent and child!
  5. Same as above, but disconnecting one write port and one read port. Now, a parent can write to its child, or a child can write to its parent, or both!
  6. Open your Core Plus in Virtual Box and open Terminal. If you forgot to bring your Tiny Core ova, do Oh No! I Forgot My Ova! Procedure.
  7. Update your work directory in KELAS/NPM/ with your revision. For example, KELAS is TESTING and your NPM is 1202000818. Please change with your class and NPM.
    $ cd TESTING/1202000818/
    $ svn update
    $ UPCEK
  8. Get your token today in apps os.
  9. Create Lab07 directory in your KELAS/NPM's directory. All your work today must be saved into Lab07's directory.
    $ mkdir Lab07
    $ svn add Lab07
    $ svn commit -m "Insert your grumble here" 
    $ cd Lab07/
  10. Download, list, extract, and delete the source file:
    $ wget --no-check-certificate https://projects.ui.ac.id/attachments/7368/Lab07.tar.bz2
    $ tar tfj Lab07.tar.bz2
    $ tar xfj Lab07.tar.bz2
    $ rm Lab07.tar.bz2
    $ ls -al
    
  11. Create and fill file "catat-Lab07.txt" with:
    ZCZC [KELAS] TGS LAB07 [NPM]
    ZCZC [TOKEN] LOG [NOTES]

    Replace [KELAS] with your class, [NPM] with your student ID, [TOKEN] with your token and [NOTES] with short notes, for example I understand that the lecturer will not give any additional homework for bonus if I flunk my score.
  12. Use record file "catat-Lab07.txt":
    $ script -a catat-Lab07.txt
  13. Write down your token, class and student ID to replace [TOKEN], [CLASS] and [NPM] inside file forknpipe01.c, forknpipe02.c, and forknpipe03.c.
  14. Study program file "forknpipe01.c".
  15. Study program file "forknpipe02.c".
  16. Write/complete program file "forknpipe03.c", where P0 sends a message to P1, P1 sends a message to P2,..., and Pn sends a message to P1.
  17. Compile and execute all files:
    $ cc -o forknpipe01 forknpipe01.c
    $ cc -o forknpipe02 forknpipe02.c
    $ cc -o forknpipe03 forknpipe03.c
    $ ./forknpipe01
    $ ./forknpipe02
    $ ./forknpipe03
    
  18. Run exit to close script "catat-Lab07.txt"
    $ exit
  19. Do MD5SUM.
  20. Please check and submit your work.
  21. Please do not forget to check repository.

Back to Wiki's Page