Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the program constructs and code snippets for the producer and consumer processes which communicate using share memory. Provide answers to the questions which

Consider the program constructs and code snippets for the producer and consumer processes which communicate (a) (b) (c) After the processes have executed for some time, it is found that out = 9 and in = 6. How many

Consider the program constructs and code snippets for the producer and consumer processes which communicate using share memory. Provide answers to the questions which follow. #define BUF_SIZE 10 typedef struct { int x = 4; char grade = 'A'; } item; Consumer Remove() while (true) { while (counter == 0) ; // do nothing // remove an item from the buffer item nextConsumed = buffer[out]; out (out + 1) % BUF_SIZE; counter--; } item buffer[BUF_SIZE]; int in = 0, out = 0, counter = 0; //Function nextProduced() creates a new item. Producer insert() while (true) { /* Produce an item */ while (counter == BUF_SIZE) ; // do nothing (keep looping) buffer[in] =nextProduced(); in = (in + 1) % BUF_SIZE; counter++ } (a) (b) (c) After the processes have executed for some time, it is found that out = 9 and in = 6. How many items are in the buffer? Make a sketch to show the position of the items in the buffer. Justify your answer. When in = out = 5, the buffer is found to be empty. Describe a sequence of events which resulted in this configuration. With reference to the code, explain what happens when in = out = 5, the buffer is empty and it's the consumer's turn to execute.

Step by Step Solution

3.49 Rating (136 Votes )

There are 3 Steps involved in it

Step: 1

Answer A Out5 In 9 this means that in the empty buffer if both the codes did execute without us... blur-text-image

Get Instant Access with AI-Powered 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

Financial Reporting Financial Statement Analysis And Valuation A Strategic Perspective

Authors: James M. Wahlen, Stephen P. Baginski, Mark Bradshaw

9th Edition

1337614689, 1337614688, 9781337668262, 978-1337614689

More Books

Students also viewed these Programming questions