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
Q. Explain about Deadlocks? Deadlocks for (int i = 0; i // first find a thread that can finish for (int j = 0; j if (!finish[j]) { boolean temp = true; for

General Graph Directory A serious trouble with using an acyclic graph structure is making sure that there are no cycles. When links are further added to an existing tree struc

Note that the parameter for scanf doesn't need the address operators & because name is an address. However the variable name has no defined space. This can cause problems within C


Explain the Per Thread Scoping Thread-level programming introduces new twists for application-level variable scoping. Threads are commonly used in one of two ways. To ex

KERNEL ACTIVITY FOR ULTS: The kernel isn't aware of thread activity but it is still managing process activity. When a thread compose a system call the whole process will be bl


EXPLAIN MULTITASKING IN DETAIL

Do ratio analysis by comparing the four companies financial statements, analysis and interpretation on the four-basic group : (Refer to attachment A) Liquidity ratio Asset

WHAT ARE THE ADVANTAGES AND DISADVANTAGES OF DUAL MODE OPERATION OF OPERATING SYSTEM>?