Producer-consumer, Operating System

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.

Posted Date: 3/13/2013 3:05:26 AM | Location : United States







Related Discussions:- Producer-consumer, Assignment Help, Ask Question on Producer-consumer, Get Answer, Expert's Help, Producer-consumer Discussions

Write discussion on Producer-consumer
Your posts are moderated
Related Questions
What are the three main activities of an operating system in regard to secondary-storage management? a) Free-space management. b) Storage allocation. c) Disk scheduling.

Enhanced Second chance algorithm In this a modify bit is as well used. Now if the ordered pair of reference and modify is (0,0) neither recently used nor modified - the best

What is critical section? Every process has a segment code called the critical section, in which the process may be updating tables, changing variables, writing file and etc. W

What are turnaround time and response time? Turnaround time is the interval among the submission of a job and its completion. Response time is the interval among submission

Q. The wait() statement in every Java program examples was part of a while loop. Describe why you would always need to use a while statement when using wait() and why you would ne

Explain about deadlock prevention? In order for the occurrence of deadlock, the four conditions like mutual exclusion, hold and wait, no pre-emption and  circular wait must hap

Write a short note about the different STATES of a process. As a process implement it changes state. The state of a process is described in part by the current activity of that

Define UFD and MFD. In the two-level directory structure, every user has her own user file directory (UFD). Every UFD has a similar structure, but lists only the files of a one

A Unix shell is a shell or command-line interpreter that gives a traditional user interface for the Unix-likesystems and for Unix operating system. Users operates the operation of

what is multilevel page table and its applications?