Synchronization and Deadlock (revision 160319-r01)

Return to Lab 05

  1. Get today's task with command:
    $ wget --no-check-certificate
  2. Look at the compressed file contents with command:
    $ tar tjf Lab05-SRC.tar.bz2
  3. Extract the compressed file with command:
    $ tar xjf Lab05-SRC.tar.bz2
  4. Delete Lab05-SRC.tar.bz2 with command:
    $ rm Lab05-SRC.tar.bz2
  5. Please edit all documents using vi in the following part:

    Change [KELAS] with your kelas, [NPM] with your NPM, For example, ZCZC REG 1202000818.
  6. Study the Makefile so that you understand how it simplifies compilation for main1, main2, main3, main4, main5, and main6.
  7. Execute Makefile document with command:
    $ make

    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.
  8. Study all .c and .h files.
  9. Please execute all programs one by one (main1 until main6).
  10. Your task is modify "main3.c".
  11. Please modify this program by modify "main2.c" to accommodate these requirements:
    1. your program should ask input of the total "masakan padang" threads to be processed.
    2. your program should produce "Thread masakan padang" with thread's number odd first and followed by even!
    3. For a clearer comprehension, look at the example of a valid result below:
  12. As an optional practice (20-30 points bonus for doing the work), modify main6.c:
    1. 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.
    2. For more information, you can see the example below:
    3. 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.
    4. For more explanation, you can see the example below:
  13. 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.
  14. This is the end of Synchronization and Deadlock Task.

Return to Lab 05
Return to Wiki

Lab05-SRC.tar.bz2 (3.14 KB) Ramot Stephanus Sihombing rast20, 19/03/2016 10:59