Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

ISBN: 978-0764535376

More Books

Students also viewed these Databases questions