Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 08 Due: Week of 11/12/2018 3. Using shared memory to communicate between a producer and a consumer process: Write a C program that will

image text in transcribed
Lab 08 Due: Week of 11/12/2018 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: tdefine MAX SIZE 8 typedef struct bufferStruct t int in; int out int content [MAX SI2E]: 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 emptyerror message should be printed. - Both programs should terminate if the user enters a 'O

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

Understand why customers complain.

Answered: 1 week ago