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 are the methods for handling deadlocks ? The technique for handling the deadlocks are: We are able to use protocol to prevent or avoid the deadlock, make sure tha

Networks and operating systems have a lot of overlap. In this course, however,we are not going to discuss networking in detail, but rather focus on the networking abstractions prov

1. Suggest some mechanism(s) to lower the dispatch latency while scheduling for a real-time system. Also, discuss any trade-off or consequent constraint associated with it, if a

Synchronization serves two purposes: 1) to ensure safety for updates on shared data (e.g. to avoid races conditions), and 2) to coordinate and order actions taken by threads (e.g.

Can you please explain in easy words how input output protection works

Demand paging gives that pages could only be brought into memory if the running process acts them. This is usually referred to as lazy evaluation as only those pages operated by

Define busy waiting and spinlock. When a process is in its significant section, any other process that tries to enter its critical section must loop continuously in the entry c

Define the OS/2 threads code The sample program in Listing is very similar to the NetWare example. OS/2 commands are substituted for the pseudocode commands controlling thread

Android operating system is an open source, Linux-based Smartphone OS. It is the world's most popular mobile platform with more than 700,000 applications and 25 billion downlo

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