Synchronization and Deadlock (revision 160319-r01)¶
Return to Lab 05
- Get today's task with command:
$ wget --no-check-certificate https://projects.ui.ac.id/attachments/download/8335/Lab05-SRC.tar.bz2
- Look at the compressed file contents with command:
$ tar tjf Lab05-SRC.tar.bz2
- Extract the compressed file with command:
$ tar xjf Lab05-SRC.tar.bz2
- Delete Lab05-SRC.tar.bz2 with command:
$ rm Lab05-SRC.tar.bz2
- Please edit all documents using vi in the following part:
ZCZC [KELAS] [NPM]
Change [KELAS] with your kelas, [NPM] with your NPM, For example, ZCZC REG 1202000818.
- Study the Makefile so that you understand how it simplifies compilation for main1, main2, main3, main4, main5, and main6.
- Execute Makefile document with command:
Hint: In this lab, when you want to change .c file, you can use command make only. You do not need to use gcc. By using make, it will detect which files are being changed and compile those files based on "make" setting.
- Study all .c and .h files.
- Please execute all programs one by one (main1 until main6).
- Your task is modify "main3.c".
- Please modify this program by modify "main2.c" to accommodate these requirements:
- your program should ask input of the total "masakan padang" threads to be processed.
- your program should produce "Thread masakan padang" with thread's number odd first and followed by even!
- For a clearer comprehension, look at the example of a valid result below:
- As an optional practice (20-30 points bonus for doing the work), modify main6.c:
- Standard challenge: Use "main5.c" and modify it so that writer and reader each takes turn to write and read. If the writer creates text, there is a reader that must be read it before another writer can write. Same condition will be happen in vice versa.
- For more information, you can see the example below:
- Advanced challenge: if your program can limit the writers so that the writer can not write again until all writers have finished writing. For example, if there are 3 writers and writer 1 has finished writing, writer 1 must wait for two other writers finish writing to be able to write again.
- For more explanation, you can see the example below:
- Once more we will remind you that main6 is NOT a task that you must do, but should you choose to do it and your work is correct you will get 20-30 bonus points depends on which challenge you've done. If you choose not to do it, you will just have to submit the default empty program.
- This is the end of Synchronization and Deadlock Task.
Return to Lab 05
Return to Wiki