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
Banker's Algorithm In this analogy Customers ≡ processes Units ≡ resources, say, tape drive Ba

Question 1 Explain the structure of operating system in detail Question 2 Explain the following scheduling algorithm                                     1) First come Firs

Facilities of a Debug Monitor Facilities of a debug monitor are like this: Setting breakpoints in the program Initiating a debug conversation while control reaches

Q. We have an OS (operating system) for a machine that uses base and limit registers however we have modified the machine to provide a page table. Can the page tables be set up to

What is preallocation? Why do it? Allocating space for a file before making the file to allow for expansion. This reserves space for a certain file so that other files can't gr

Q. Give an instance of an application in which data in a file should be accessed in the following order: a. Sequentially b. Randomly Answer: a. Print the content of

When a computer is started on, the program that executed first is named the ''operating system.'' It controls pretty much all applications in the computer. This adds who logs in, h

advantage and dis advantage of threads

Explain the Spawnvp Function used in the netware Spawnvp(flags, execNmae, argv)   This function executes  similarly to spawnlp( ) except that parameters are passed as a v

How the Nested Macro calls are expanded LIFO (Last in First out)