Question: Skeleton of buffer.c Problem Statement: Read through Project 3 (page 253-255) in the textbook, the Producer-Consumer Problem, and finish it using Pthreads only (ignore the

 Skeleton of buffer.c Problem Statement: Read through Project 3 (page 253-255)

in the textbook, the Producer-Consumer 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

Skeleton of buffer.c

in screenshots similar as the sample screenshots shown below. The three scenarios

are: 1) more producers than consumers; 2) more consumers than producers; 3)

Problem Statement: Read through Project 3 (page 253-255) in the textbook, the Producer-Consumer 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. Please refer to the screenshots shown below for sample outputs under different scenarios. (Your outputs may be different) 3. The main O function will be passed four parameters on the command line. The four parameters are 1. 2. How long will the main thread sleep before terminating T 3. 4. he number of producer threads The number of consumer threads The initial value of the number (for producers) Your program should be executed like this /buffer . Here buffer is your executable file which is followed by four parameters, sleep time, the number of producer threads, the number of consumer threads, and the initial number. Eg. ./buffer 10 2 2 10 Some Notes: 1. To help you to get started, a skeleton of the buffer.c is provided in iCollege. 2. To get a thrcad's ID, you may call the pthrcad sclf) function and convert the result into an integcr. Bclow is a samplc showing how a thrcad can get and print its ID printf("Consumer %u consumed %d " ,(unsigned int)pthread self(), random); 3. Using gec -pthread -o buffer buffer.c to compile, and then an executable file buffer would be generated. (Suppose buffer.c is your code file) Problem Statement: Read through Project 3 (page 253-255) in the textbook, the Producer-Consumer 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. Please refer to the screenshots shown below for sample outputs under different scenarios. (Your outputs may be different) 3. The main O function will be passed four parameters on the command line. The four parameters are 1. 2. How long will the main thread sleep before terminating T 3. 4. he number of producer threads The number of consumer threads The initial value of the number (for producers) Your program should be executed like this /buffer . Here buffer is your executable file which is followed by four parameters, sleep time, the number of producer threads, the number of consumer threads, and the initial number. Eg. ./buffer 10 2 2 10 Some Notes: 1. To help you to get started, a skeleton of the buffer.c is provided in iCollege. 2. To get a thrcad's ID, you may call the pthrcad sclf) function and convert the result into an integcr. Bclow is a samplc showing how a thrcad can get and print its ID printf("Consumer %u consumed %d " ,(unsigned int)pthread self(), random); 3. Using gec -pthread -o buffer buffer.c to compile, and then an executable file buffer would be generated. (Suppose buffer.c is your code file)

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!