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
what is meant by lazzy swapper

Explain Deadlock Every process in a set of processes is waiting for an event which only a process in the set can cause.

LRU approximation page replacement In this we are able to use the reference bit associated with the page entry to choose a page to be removed. The various algorithms used for

System Service Program system service program Supports and provides the services for other program. System service program perform Varity of tasks.  They are further divided in

Q. What are the major differences between capability lists and access lists? Answer: An access list is a list for each object consisting of the domains with a nonempty set of


Define the properties operating systems: Batch :- Jobs with similar needs are batched together and  run through the computer as a group by an operator or automatic job sequenc

Gopher Gallery consists of a shopping mall and a cart ride that covers the 150 acre habitat. There are m visitors and n single-person vehicles. Visitors stroll around the mall at

What is an acyclic graph? A tree that has been corrupted by links to other branches, but does not have any cyclic paths in it.

Why interrupt can be used? The majority of the different parts of the PC need to send information to and from the processor and they expect to be able to get the processor's at