Producer – consumer process, Operating System

Step by step displays the content, and the final result of the list ("buffer") of 6 elements as the initial values ??and the following elements which are produced (NEXTP) or consumed (NEXTC). This scheme allows a maximum of (Buffer_size - 1) elements.

#define BUFFER_SIZE 6

typedefstruct { ....}item;

item buffer[BUFFER_SIZE];

int    in   0;

int  out   0;

         Producer

         itemnextProduced;

                  while (true)   

                  {.../* produce an item in nextp  */

                           while  (((in + 1)  %  BUFFER_SIZE )  = =  out)   

                                                                                     /* loop, do nothing */;

                           buffer[in]   nextp;

                           in   (in + 1)  %  BUFFER_SIZE;

                  }

 Consumer

         itemnextConsumed

                  while (true)

                  {...

                           while  ( in  = = out) ;       /* loop, do nothing */;

                           nextc = buffer [out];

                           out   (out + 1)  %  BUFFER_SIZE;

                                    /*  consume the item in nextc  */

                  }

Posted Date: 3/20/2013 2:04:34 AM | Location : United States







Related Discussions:- Producer – consumer process, Assignment Help, Ask Question on Producer – consumer process, Get Answer, Expert's Help, Producer – consumer process Discussions

Write discussion on Producer – consumer process
Your posts are moderated
Related Questions

For the first assignment you are required to construct a logic circuit onto a copper clad circuit board (vero board). This construction will require the use of planning the positio

Q. A CPU scheduling algorithm determined an order for the execution of its scheduled processes. Convinced n processes to be scheduled on one processor how numerous possible differ

Q. What is the effect of permitting two entries in a page table to point to the same page frame in memory? Describe how this effect could be used to decrease the amount of time ne

Q. Why do some systems stay track of the type of a file while others leave it to the user or simply don't implement multiple file types? Which system is "better?" Answer: A f

FIRST FIT ALGORITHM Scanning a list along with if a free hole is available with necessary space for the process to allocate it allocates the process in that space. The first s

Many-to-Many Model The many-to-many model- many user-level threads to many kernel-level threads avoids several of the limitations of the one-to-one model, although extending mu

Q. Several CPUs provide for more than two modes of operation. What are two probable uses of these multiple modes? Answer: Although most systems merely distinguish between use

Fault tolerance : Machine failures, Communication faults, storage device crashes, and decays of storage media must be tolerated by the system to some extent. A fault tolerant sy

What are the different files attributes? File name:-it's the name of the file. It's the name with which the user identifies. Identifiers:-it's created when a file is created