Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Using shared memory to communicate between a producer and a consumer process: Write a C program that will produce items and place them in

image text in transcribedimage text in transcribed

3. Using shared memory to communicate between a producer and a consumer process: Write a C program that will produce items and place them in a shared buffer and another program that will read these items and consume them (i.e. process them). The 2 processes will use a shared memory to represent the buffer that the producer will write to and the consumer will read from Since the speeds of the processes are different, the shared memory should also have 2 variables/pointers (in, out) that both processes can access and use to synchronize the use of the buffer: o When in - out: buffer is empty of new items, and reader should stop; o When in+1-out: buffer is full, and writer should stop; Refer to slides 15-17 in "Lec_04 b Communication Between Processes" for More details on how the producer and the consumer processes should function Use the following data structure to represent the data that will be shared between the producer and the consumer processes Note: All labs are due before next week's lab starts Lab 08 CIS 370 Due: Week of 11/12/2018 #de fine MAX SIZE 8 typedef struct bufferStruct int in; int out; int content [MAX SIZE];// will hold ASCII calues of characters }bufferStruct; -Every time the user hits enter in the producer process, it should generate random integer value and store it into the shared buffer until the buffer is full. If the user hits enter after that then a "buffer is full.." error message should be printed. -Every time the user hits enter in the consumer process, it should consume the oldest item in the buffer and print it to the screen, until the buffer is empty. If the user hits enter after that then a "buffer is empty ..." error message should be printed Both programs should terminate if the user enters a '0

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: 3

blur-text-image

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago