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;



                  while (true)   

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

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

                                                                                     /* loop, do nothing */;

                           buffer[in]   nextp;

                           in   (in + 1)  %  BUFFER_SIZE;




                  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 Threads for Executing Concurrent Application Code The thread has been introduced in many operating systems as an efficient mechanism for executing concurrent applicatio

Q. Explain about Error detection method? Error detection: error can occur in CPU, in I/O devices or in memory hardware. Operating system constantly needs to be aware of possi

When the Page fault frequency in an operating system is reduced Locality of reference is appropriate to the process

Elimination of common sub expression during code optimization An optimizing transformation is a rule for rewriting a section of a program to enhance its execution efficiency wi

Device Drivers Communicates straight with peripheral devices (disks, tapes, etc.). Responsible for begin physical I/O operations on the device. Pro

In this project, you will implement the Chandy and Misra's (CM) algorithm using POSIX Threads (Pthreads).   The algorithm  is a distributed algorithm to solve a generalized dining

What is the difference between multiprocessing and multitasking? Multi programming means implementing more than one program but here whenever the processor is idle during execu

What are three conditions that a solution for the critical section problem must satisfy? The three conditions are as following:- a)      Mutual exclusion :- if a process is