100 likes | 349 Views
Homework Assignment #2. Hsung-Pin Chang Department of Computer Science and Engineering National Chung Hsing University. Homework Assignment #2-1. In text book page no.227 page Exercise 6.8: The Sleeping-Barber Problem.
E N D
Homework Assignment #2 Hsung-Pin Chang Department of Computer Science and Engineering National Chung Hsing University
Homework Assignment #2-1 • In text book page no.227 page • Exercise 6.8: The Sleeping-Barber Problem. • Print all the messages corresponding to each customer and the barber’s behavior. NCHU System & Network Lab
Homework Assignment #2-2 Semaphore-based solution NCHU System & Network Lab
Homework Assignment #2-2 Implement a solution to the producer consumer problem using the producer and consumer processes shown in the previous slide. Create three producer threads and three consumer threads. The producer and the consumer threads share a buffer with four character slots. The producer thread will alternate between sleeping for a random period of time and inserting the uppercase alphabets in order into the buffer. The consumer also sleep for a random period of time and will attempt to remove an item from the buffer. The main()will sleep for a period of time and upon awakening, will terminate the application. NCHU System & Network Lab
Turn In • The homework which you upload • Source code • Executing result (snapshot) NCHU System & Network Lab
Turn In • Deadline : 2007/12/5 23:59 • Pack homework into a RAR file and upload to • ftp:// 140.120.15.117:1003 • ID: os96 PW: os96 • Filename format • ex: HW2_79556042_蘇榮柏.rar • If you want to update • ex: HW2_79556042_蘇榮柏v2.rar NCHU System & Network Lab
Turn In • TA info. • Name • 蘇榮柏 甘惠文 邱顯泰 邱俊肇 • Lab • 系統與網路實驗室 1003A • E-mail (follow name sequence) • s9556042@cs.nchu.edu.tw • s9556043@cs.nchu.edu.tw • s9556045@cs.nchu.edu.tw • s9556048@cs.nchu.edu.tw NCHU System & Network Lab
Turn In • No late work is acceptable • You get zero if you miss the due day • No cheat work is acceptable • You get zero if you copy other people’s version NCHU System & Network Lab