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
Assume there are only 4 page frames in the physical memory, for the following reference string: 1, 2, 3, 4, 5, 3, 4, 1, 6, 7, 8, 7, 8, 9, 7, 8, 9, 5, 4, 5, 4, 2, 8. a) What i

Question: (a) Write down short notes on the different versions of Windows server 2003 mentioned below: 1. Windows Server 2003, Web Edition 2. Windows Server 2003, Stand

File allocation using I nodes. This method is used to decrease the size of the table in the above method. Every file will have an I-node list. Allow a file have 15 pointers a

Q. Could you replicate a multilevel directory structure with a single-level directory structure in which arbitrarily long names can be used? If your answer is yes describe how you


Q. How does DMA raise system concurrency? How does it make difficult hardware design? Answer: DMA increases system concurrency by allowing the CPU to perform tasks while the

Write a short note on peer-to-peer computing. Peer-to-peer (P2P) system model is a kind of distributed OS. In this model, clients and servers aren't distinguished from one anot

swapping technique

Question: OS Installation / File system a) Why is NTFS portioning preferred over FAT16 or FAT32 when security is of primary concern? b) State a situation or an application w

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