Question: Producerconsumer problem Write a java program which understands the behavior of two synchronized concurrent processes using Producerconsumer problem; The progamme must do the following :

Producerconsumer problem

Write a java program which understands the behavior of two synchronized concurrent processes using Producerconsumer problem;

The progamme must do the following :

1) Given a statement

S-screate(p); where 'S' is name of Semaphore; and 'p' is the integer constant used to intialse the value of the semaphore, it will set up the semaphore 'S' intialsing and setting up the associate waiting queue

2) Given a command Wait(S); where Wait is a keyword and 'S' is a Semaphore; it will implement the semantics of wait

3) Given a command Signal(S); where signal is a keyword and 'S' is a Semaphore; it will implement the semantics of signal.

4) finally the program should trace the excecution of arbitrary but valid sequence by two synchronized concurrent processes by semaphore

Point to consider:

You do not need the declarations etc.

No need to spawn two processes, using resume and create, prod and cons. We assume that the corresponding programs, prod2 and cons2 suffice.

The body of prod2 and cons2 contain only the labeled statements involving wait and signal.

Your output must display

The value and the status of the semaphore queue; the instructions being executed at each cycle; and annotations explaining the event that arises in each cycle meaning why a particular command in the arbitrary sequence is not valid and hence ignored.

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!