Producer-consumer, Operating System

Assignment Help:

The general idea of a producer-consumer architecture is related to building a pipeline of threads, similar to the web spider from Project 2. Each step of the processing will now be done by a specialized threads; whenever one thread is done with its part of the processing, it forwards the data to the next stage of the pipeline, like a factory assembly line. In a producer-consumer system, we guarantee that each stage of the pipeline signals the next stage of the pipeline when it completes its task, and blocks when there's nothing else for it to do, etc.

If we were to implement our web server in a producer-consumer fashion, we could simply create a pair of threads: one for reading the URL requested by the client, and another one for writing the answer back to the network. We could also create yet another intermediate thread, which would ?rst look for the URL in a cache. This intermediate threadmight help the overall average response time of the system, if we can implement the shortest time to completion ?rst policy, i.e. ?nish the easy things ?rst, which leads to the lowest average response time.

As with the thread pool approach, it is not always clear how many threads we need for each of stage of the pipeline; the exact amount depends on the application and is usually ?ne-tuned manually. Since each thread has a specialized task, if the number of threads for each task is not well-tuned, then many threads might be idle, wasting resources.

In general, the producer-consumer approach works well if the producer and the consumer are symmetric, i.e. if they proceed roughly at same rate. On the other hand, if the order of processing doesn't matter, it doesn't make sense to use a producer-consumer architecture, with its ordered pipeline of processing.


Related Discussions:- Producer-consumer

Explain what is semaphores, Explain what semaphores are, their usage, imple...

Explain what semaphores are, their usage, implementation given to avoid busy waiting and binary semaphores. Semaphore definition Usage for mutual exclusion and process synch

What is the design issues involved in segmentation?, SEGMENTATION HARDWARE ...

SEGMENTATION HARDWARE An execution to map two-dimensional user-defined addresses into one-dimensional physical addresses. This mapping is affected by means of segment table. Ev

Define a public key encryption system, Define a public key encryption syste...

Define a public key encryption system Allows just the correct receiver to decode the data

Problem of unbalanced loads, Present your own fully documented and tested p...

Present your own fully documented and tested programming example illustrating the problem of unbalanced loads. Describe the use of OpenMP's scheduler as a means of mitigating this

Binary arithmetic, The principle is that of ordinary addition; however reme...

The principle is that of ordinary addition; however remember the highest number is 1.   Calculate the following:                             11001 +                           11

Several cpu-scheduling algorithms, Q. Several CPU-scheduling algorithms are...

Q. Several CPU-scheduling algorithms are parameterized for instance the RR algorithm requires a parameter to indicate the time slice. Multilevel response queues require parameters

Benefits of dynamic linkage of libraries, Q. What are three benefits of dyn...

Q. What are three benefits of dynamic (shared) linkage of libraries compared to static linkage? What are two situations where static linkage is preferable? Answer: The

Unix process api, Unix process API The two most important function calls...

Unix process API The two most important function calls to use when programming with several processes are fork and exec:  fork() creates a copy of current process. It gives

Linux, Discuss the risks of having a single root user

Discuss the risks of having a single root user

Explain beladys anomaly, Explain Belady's Anomaly? Also called FIFO ano...

Explain Belady's Anomaly? Also called FIFO anomaly. Usually, on enhancing the number of frames allocated to a process virtual memory, the process implementation is faster, beca

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