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
Explain segmentation hardware? We define an completion to map two-dimensional user-defined addresses into one-dimensional physical addresses. This mapping is affected by means

Explain Wait for Graph a. Use a resource allocation graph to derive a wait-for graph.  b. Wait-for graph acquired by making an edge from p 1 to p 2 iff p 1 is waiting for

i am just wondering if you have expert in nachos operating system thank you

Explain what semaphores are, their usage, implementation given to avoid busy waiting and binary semaphores. Semaphore definition Usage for mutual exclusion and process synch

Question 1: a) State the different file attributes and briefly explain the operations that can be performed on each files. b) What is a semaphore? Describe why it is impor


Explain about deadlock detection? In deadlock situation, the system must provide An algorithm that verifies the state of the system to verify whether a deadlock has occu

What are the disadvantages of linked allocation? The drawbacks are a. Used only for sequential access of files. b. Direct access is not supported c. Memory space neede

Describe the differences among short-term, medium-term, and long-term scheduling.   Short-term (CPU scheduler)-selects from jobs in memory those jobs that are ready to execu

Define Coding in an independent service architecture Coding in an independent service architecture alleviates many of the traditional dependencies of monolithic applications.