Question

Show the content of buffer, in, and out for the following operations. Assume that there are...

Show the content of buffer, in, and out for the following operations.

Assume that there are two operations; producer and consumer and the size of the buffer is 5.

You should draw the array on every operation.

Producer (“A”);

Producer (“B”);

X= Consumer ();

Y= Consumer ();

Producer (“C”);

Producer (“D”);

Producer (“E”);

X= Consumer ();

X= Consumer ();

Producer(“F”);

Y= Consumer();

Homework Answers

Answer #1

Producer Consumer Problem:

Producer consumer problem is also called as Bounded buffer problem. It is the classic problem of synchronization. The problem is here we will have a n number of slots called a buffer capable of storing one unit of data in one slot and there works 2 operations called producer and consumer. The producer will add the data to the buffer and the consumer operation will remove the data from the buffer. While the producer will add the data buffer size increases and if it is consumer, the buffer size will decrease. The producer and the consumer should work independently, so that we use semaphores to solve this problem.

Here we use wait and signal operations for the semaphore problems. wait means putting the lock to not access others into buffer and singal means giving access to the other to enter into the buffer.

The producer operation will work as below:

do 
{
    wait(empty);   
    wait(mutex); 
    signal(mutex); 
    signal(full);   
} 
while(TRUE)

Here empty and mutex are the terms that helps to work the producer operation in a better way. wait(empty) will used to take count of the data in buffer which is adding. wait(mutex) will make it locked and not allows the consemer to not enter. signal(mutex) will unlock the lock and signal(full) will increase the count of buffer after the producer comes out from the buffer.

Consumer operation will works as below:

do 
{
    wait(full);
    wait(mutex);  
    signal(mutex); 
    signal(empty); 
} 
while(TRUE);

Here wait(full will hold the producer to not change the buffer size while the consumer will be there in the buffer. wait(mutex) will locks the buffer to not allow the producer inside. signal(mutex) will unlock the buffer to give access to the producer to enter into the buffer. signal(empty) will decrease the buffer count after the consumer takes out the data.

Given operations are:

Producer (“A”);

Producer (“B”);

X= Consumer ();

Y= Consumer ();

Producer (“C”);

Producer (“D”);

Producer (“E”);

X= Consumer ();

X= Consumer ();

Producer(“F”);

Y= Consumer();

Below are the required array diagrams of given operations in the question.

From the above we can say that producer will produce from the left side of the array into buffer and consumer will take out the data from the right side of the array from the buffer. That is when producer produces data means it is considered as buffer in and the consumer consumes the data means it is considered as buffer out.

                     Hope the above is helpful. Please feel free to comment if any queries in the

                                 comment section. I will try to solve them as soon as possible.

                                            Do an up vote. Thank you..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Assume you have a stack and a queue implemented using an array of size 4. show...
Assume you have a stack and a queue implemented using an array of size 4. show the content of the array for the stack (then the queue) for the following operations: (for the queue replace push by add and pop by remove; keep in mind that the queue uses a circular array): push(-3), push(-5), push(-9), push(-10), pop(), pop(), push(-13), pop(), push( -15), push(-17).
4.Consider the following supply and demand equations: Supply:p= 10 +q Demand:p= 100−2q Show your work as...
4.Consider the following supply and demand equations: Supply:p= 10 +q Demand:p= 100−2q Show your work as your response to the following questions. (a) What is the market equilibrium price and quantity?(5%) (b) Draw a diagram to clearly show the market equilibrium.(5%) (c) What is the Consumer Surplus at equilibrium?(5%) (d) What is the Producer Surplus at equilibrium?(5%) (e) What is the Total Surplus at equilibrium?(5%)
Qd= 20-2P and Qs= 3P. a) Draw the demand and supply curves. b)What is the equilibrium...
Qd= 20-2P and Qs= 3P. a) Draw the demand and supply curves. b)What is the equilibrium point. c) Computer initial Consumer Surplus, CS0. Show work. d) Computer initial Producer Surplus, PS0. Show work. e) Computer initial Total Surplus. TS0. Show work. f) Supposed a $5 tax, T=5, has been levied on consumers. (i) Compute the new demand curve (ii) Draw the new demand curve in (a). g) Compute the DWL of the consumer and the producer after tax. h) Compute...
1. Consider the following demand and supply functions for a good or service: Qd = 400...
1. Consider the following demand and supply functions for a good or service: Qd = 400 - 5P and Qs= 3P. a) Graph the supply and demand functions in the typical manner with price per unit (P) on the Y-axis and quantity on the X-axis. Make sure to clearly mark X-intercept and Y-intercept on the graph. b) What is the slope of each line? Show your calculations. c) What is the equilibrium price and quantity? Show your calculations. Show the...
1.) In tracing out a price consumption curve for a good x, which of the following...
1.) In tracing out a price consumption curve for a good x, which of the following variables are held constant? Select all that apply a.) consumer income b.) consumption of y. c.) the price of good x d.) utility e.) the price of good y 2.) The demand curve maps out a.) the optimal quantities of x and y change as income changes, ceteris paribus. b.) the optimal quantity of one good and the price of that good, ceteris paribus....
Given the following sequential list of VEX operations: A. add $r3 = $r1, $r2 B. sub...
Given the following sequential list of VEX operations: A. add $r3 = $r1, $r2 B. sub $r8 = $r1, $r3 C. sub $r7 = $r1, 2 D. add $r1 = $r1, 1 E. mpy $r6 = $r3, $r2 Which VEX operations can be scheduled simultaneously to make up the second VLIW instruction? The constructed schedule should satisfy the following conditions: Assume infinite resources and no limit to the number of operations scheduled to a single instruction. Operations that are scheduled...
for each of th ebasic blocks , determine the order of execution of operations that gives...
for each of th ebasic blocks , determine the order of execution of operations that gives the smallest number of required registers. Next, stat the number of registers required in each case. (you can assume that all computed values are used outside the basic blocks, so that no assignments can be eliminated) 1) x = a+b; y = c + d; z = x + e 2) w = a-b +c; x = w -d ; y = x-2 ;w...
F(x, y) = yi + xj (a) Show F is conservative Given your answer in (a)...
F(x, y) = yi + xj (a) Show F is conservative Given your answer in (a) show that the following integrals have the same value. (b) The line segment y = x from (0,0) to (1,1). (c) The parabola y=x^2 from (0,0) to (1,1). (d) The cubic y=x^3 from (0,0) to (1,1). (e) The b, c and d are examples of what property resulting from part a?
Use the following information to answer the next five questions. The following buffer was prepared: 50....
Use the following information to answer the next five questions. The following buffer was prepared: 50. mL 2.0 M methylamine (CH3NH2) solution and 50. mL of 2.0 M methylamine hydrochloride (CH3NH3Cl) solution. The Kb for methylamine is 4.4 x 10-4. 1. What is the pH of the buffer solution? a) 11.12                           b) 10.64                       c) 12.32                       d) 0.48                         e) 5.32 2. What is the pH of the resulting solution after adding 100 ml of 1.0 M HCl to...
#9) You are to implement the following function F(A,B,C,D,E,F) which outputs a 1 whenever the binary...
#9) You are to implement the following function F(A,B,C,D,E,F) which outputs a 1 whenever the binary number represented by ABCDE is ODD and 0 otherwise. A is the MSB and E is the LSB. Draw the function F(A,B,C,D,E,F) and show the work that led you to that answer. Since I am not so sadistic as to have you draw the truth table of a 6 variable function and draw the K-map of such a function, you should realize, as a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT