- 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.
- 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.
- You can create a pipe in a process with system call pipe(), but it is less fun:
- A forked process and pipe (some fun). Whatever a process (parent or child) writes, can be read by both parent and child!
- 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!
- 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.
- 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
- Get your token today in apps os.
- 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/
- 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
- 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.
- Use record file "catat-Lab07.txt":
$ script -a catat-Lab07.txt
- Write down your token, class and student ID to replace [TOKEN], [CLASS] and [NPM] inside file forknpipe01.c, forknpipe02.c, and forknpipe03.c.
- Study program file "forknpipe01.c".
- Study program file "forknpipe02.c".
- 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.
- Compile and execute all files:
$ cc -o forknpipe01 forknpipe01.c
$ cc -o forknpipe02 forknpipe02.c
$ cc -o forknpipe03 forknpipe03.c
- Run exit to close script "catat-Lab07.txt"
- Do MD5SUM.
- Please check and submit your work.
- Please do not forget to check repository.