Lab05 Thread and Synchronization (revision 131010-r01KI)

  1. 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.
  2. 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
  3. Get your token today in apps os.
  4. Create Lab05 directory in your KELAS/NPM's directory. All your work today must be saved into Lab04's directory.
    $ mkdir Lab05
    $ svn add Lab05
    $ svn commit -m "Lab 05 is not challenging, can I have something more difficult?" 
    $ cd Lab05/
  5. Get today's task with command:
    $ wget --no-check-certificate https://projects.ui.ac.id/attachments/7284/Lab05-SRC.tar.bz2
  6. Look at the compressed file contents with command:
    $ tar tjf Lab05-SRC.tar.bz2
  7. Extract the compressed file with command:
    $ tar xjf Lab05-SRC.tar.bz2
  8. Delete Lab05-SRC.tar.bz2 with command:
    $ rm Lab05-SRC.tar.bz2
  9. Please edit all documents using vi in the following part:
    ZCZC [TOKEN] [NPM]

    Change [TOKEN] with your token, [NPM] with your NPM, For example, ZCZC NO4LAY 1202000818.
  10. Study the Makefile so that you understand how it simplifies compilation for main1, main2, main3, main4, main5, and main6.
  11. 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.
  12. Study all .c and .h files.
  13. Please create "catat-Lab05.txt" with contents:
    ZCZC [KELAS] TGS LAB05 [TANGGAL]
    ZCZC [TOKEN] LOG [KETERANGAN]
    

    Change [KELAS] with your class, [TANGGAL] with today's date with format DD-MM-YY, [TOKEN] with your token, and [KETERANGAN] with short explanation.
    ZCZC TESTING TGS LAB05 28-02-2013
    ZCZC NO4LAY LOG This is too easy!
    
  14. Please capture the output in the screen during the thread's tutorial and synchronize by using command:
    $ script -a catat-Lab05.txt
    
  15. Please execute all programs one by one (main1 until main6).
  16. Your task is modify "main3.c" and "main6.c".
  17. For main3.c:
    1. Please modify this program by modify "main2.c" so that it can produce "Thread masakan padang" with thread's number odd first and followed by even!
    2. For more explanation, you can see the example below:
    3. Bonus 10% if your program can ask input of the total "masakan padang" threads to be processed.
    4. For a clearer comprehension, look at the example below:
  18. For main6.c:
    1. 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. Bonus 10% 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:
  19. After executing all program, please stop "script" program with command:
    $ exit
    
  20. Do MD5SUM.
  21. Please check and submit your work.

Back to Wiki's Page