![]() The array of buffer item objects will be manipulated as a circular queue. The Buffer Internally, the buffer will consist of a fixed-size array of type buffer item (which will be defined using a typedef). You can solve this problem using either Pthreads or the Windows API. The producer and consumer-running as separate threads-will move items to and froma buffer that is synchronizedwith the empty, full, andmutex For this project, you will use standard counting semaphores forĮmpty and full and a mutex lock, rather than a binary semaphore, to represent mutex. The solution presented in Section 5.7.1 uses three semaphores: empty and full, which count the number of empty and full slots in the buffer, and mutex, which is a binary (or mutualexclusion) semaphore that protects the actual insertion or removal of items in the buffer. Writes to buffer at index next_in and consumer reads at index next_out.Īmong the includes at the beginning of bounded-buffer.Design a programming solution to the bounded-buffer problem using the producer and consumer processes shown in Figures 5.9 and 5.10. P producers and C consumers using a shared bounded buffer of size N. A producer will signal this semaphore after writing to the buffer.A consumer must wait on this semaphore before reading from the buffer.Use one semaphore named data to count the number of data items in the buffer. A consumer will signal this semaphore after reading from the buffer.A producer must wait on this semaphore before writing to the buffer.Use one semaphore named empty to count the empty slots in the buffer. Two counting semaphores can be used for this. Consumers must block if the buffer isĮmpty. ![]() ![]() Producers must block if the buffer is full.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |