Question: Read through Project 3 (page 253-255) in the textbook, the ProducerConsumer Problem, and finish it using Pthreads only (ignore the Windows API part). Your project

 Read through Project 3 (page 253-255) in the textbook, the ProducerConsumerProblem, and finish it using Pthreads only (ignore the Windows API part).

Read through Project 3 (page 253-255) in the textbook, the ProducerConsumer Problem, and finish it using Pthreads only (ignore the Windows API part). Your project must meet the following requirements for full credit:

1.Instead of generating random numbers and write to the buffer, producer threads will write incremental integers into the buffer. For example, if the initial value of the number is 10, then the next number should be 11, and the next will be 12....

2.Create producer and consumer threads with 3 scenarios and show your results in screenshots similar as the sample screenshots shown below. The three scenarios are: 1) more producers than consumers; 2) more consumers than producers; 3) same number of producers and consumers.

Project 3 Producer-Consumer Problem tion 5.7.1, we presented a semaphore-bascd olution to the producer consumer problem using a bounded buffer. In this project, you will design a programming solution to the bounded-buller problem using the producer and consumer processes shown in Figures 5.9 and 5.10. The solution presented in Section 5.7.1 uses three semaphores: empty and full, which count the number empty and full slots in the buffer, and mutex, which is a bina (or mutual exclusion) semaphore that protects the actual insertion or removal of items in the buffer. For this project, you will use standard counting semaphores for empty and full and a mutex lock, rather than a binary semaphore, to represent text. The producer and consumer running as separatc threads will move items to and from a buffer that issynchronizcd with the em full, and mutex structures. You can solve this problem using either Pthreads or the Windows API

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!