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
Sir i want formulas in Memory management starting from paging till the demang paging in a easy manner for solving problems in competitive exams

Discuss in detail Table management Techniques?     An Assembler employs the subsequent tables: OPTAB: Operation Code Table consists of mnemonic operation code and its machi

From hardware perspective, every information system can be divided into three task areas Presentation, Application Logic and Data Storage. The R/3 Basis software is extremely s

Q. Why is it significant to balance file system I/O among the disks as well as controllers on a system in a multitasking environment? Answer: A system can perform mere

Question: a) Windows Server 2003 has brought great enhancements the Server System as compared to the previous version. Write down short notes on the below listed enhancements.

Define the Global vs. local variables It is also important to discuss the scope of resources being granted to the application program.  Variable scoping is defined as the acces

What are the methods for handling deadlocks? The deadlock problem can be dealt with in one of the three ways: a. Use a protocol to prevent or avoid deadlocks, ensuring that

Effects of multiprogramming on resource utilization With the utilize of multiprogramming, batch processing is able to be quite efficient .Just as multiprogramming permits the

Q. Why would it be an awful idea for gateways to pass broadcast packets between networks? What would be the merite of doing so? Answer: All broadcasts would be spreads to all

Binary number based systems   Binary is a  ' base 2' number system, only two numbers exist namely '0' and '1'. Conversion from binary to base 10 is easy if the number column techn