Question: Operating Systems Using Pthreads for Bounded Buffer The purpose of this project is to provide you with some hands-on experience i n using s tandard

Operating Systems

Using Pthreads for Bounded Buffer

The purpose of this project is to provide you with some hands-on experience in using standard pthreads library to solve producer-consumer problem. For more information on pthreads, you may review the pthreads Web page and the tutorial from Lawrence Livermore National Lab.

In this project, you will design a programming solution to the bounded-buffer problem by using the producer and consumer processes described in process synchronization chapter of your textbook. The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time the consumer is consuming the data (i.e. removing it from the buffer) one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer.

The solution for the producer is to go to sleep if the buffer is full. The next time the consumer removes an item from the buffer, it wakes up the producer who starts to fill thebuffer again. In the same way the consumer goes to sleep if it finds the buffer to be empty. The next time the producer puts data into the buffer, it wakes up the sleeping consumer. The solution can be reached by means of inter-process communication, typically using semaphores. Your solution should avoid any deadlock situation that might occur. The size of the buffer used by the producer and the consumer is 7.

The solution presented in the textbook 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 mutual exclusive) semaphore that protects the actual insertion or removal of items in the buffer.

For this project, standard counting semaphores will be used for empty and full, and a binary semaphore, mutex lock,will be used to represent mutual exclusion. The producer and consumer running as separate threads will move random number of items to and from a buffer that issynchronized with these empty, full, and mutex structures. You are required to use the pthread package to solve this problem in this project.

Programming Tool:

You can use either C or C++.

Project Submission:

1. Write a short report describing:
i. The problem and states any assumptions that you might made to solve this problem.
ii. Pthread system calls that you used in this project.
iii. Steps that you used to run your programs. Provide the images for the capturing screens to verify the operation of your work.
iiii. The results you obtained.

2. Compress your report and program and uploaded to Canvas. The name of the submitted project has to beas follows: your name-your department-course number.

3. Comments should be provided with your program.

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!