![]() circular-queue) with n buffers, each capable of holding a single value of data type double. Additional students files associated with this lab, as well as any existing solutions can be provided upon request by e-mail to: perronebucknelleduĪssume that you have a circular-list (a.k.a. Permission to reuse this material in parts or in its entirety is granted provided that this credits note is not removed. In this lab, you will learn to work with these two mechanisms for thread synchronization as you implement a solution to the bounded-buffer problem. Fortunately, POSIX gives you the more general-purpose semaphore in the sem_t data data type. Learn to work with Unix and Pthread synchronization mechanisms.The Pthread library offers the pthread_mutex_t data type, which is much like a binary semaphore and therefore somewhat of limited utility in the solution of synchronization problems. ![]() Writes to buffer at index next_in and consumer reads at index next_out.Īmong the includes at the beginning of bounded-buffer. 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. |