Producer – consumer process, Operating System

Assignment Help:

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  */

                  }


Related Discussions:- Producer – consumer process

Explain the overlay structured program, Overlay structured program: A p...

Overlay structured program: A program consisting of overlays is referred as overlay structured program in which an overlay is a part of program which has similar load origin as

Write a note on deadlocks, Write a note on deadlocks. The proper defini...

Write a note on deadlocks. The proper definition of deadlock A set of processes is deadlocked if every process in the set is waiting for an event that only a proces

How does dma raise system concurrency, Q. How does DMA raise system concurr...

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

Mutual exclusion, With software algorithms for mutual exclusion, such as De...

With software algorithms for mutual exclusion, such as Dekker's algorithm, Peterson's algorithm, or Lamport's bakery algorithm, note that optimizing compilers and out-of-order exec

Explain process scheduling in multiprogramming, Normal 0 false ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

What is preemptive and nonpreemptive scheduling, What is preemptive and non...

What is preemptive and nonpreemptive scheduling? Under nonpreemptive scheduling once the CPU has been allocated to a process, the process keeps the CPU unless it releases the C

Write pseudo code to implement the pthread create wrapper, Write pseudo cod...

Write pseudo code to implement the pthread_create wrapper of the Tern memoizer. Note you need to describe your data structure for maintaining deterministic thread IDs. In addition,

Operating system strectures, with the aid of diagrams describe the followin...

with the aid of diagrams describe the following os structures monolithic , layered, client server

What is a client server system, What is a client server system? Central...

What is a client server system? Centralized systems proceed as server systems to satisfy request generated by client systems Server system is able to be broadly div

Threads, What is single and multithreading and thread pool?

What is single and multithreading and thread pool?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd