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
Explain the Fork Function Fork function causes a new process to be created. The calling progress is duplicated as an exact copy (called the child process) that differs only in

Gopher Gallery consists of a shopping mall and a cart ride that coversĀ  the 150 acre habitat. There are m visitors and n single-person vehicles. VisitorsĀ  stroll around the mall at

Q. Explain about Deadlocks? Deadlocks for (int i = 0; i // first find a thread that can finish for (int j = 0; j if (!finish[j]) { boolean temp = true; for

As mentioned earlier, the game engine will be used as the base of developing the Go game for the Android. This includes improving logic of the game, design good graphics and optim

Now we consider the following questions: how can the parent process communicate with its child? Or how can children processes communicate with other children? The exact answer depe

In a multiprogramming and time sharing environment several users share the system simultaneously .what are two such problems?

Define properties of Distributed operating system Distributed:- This system distributes computation among several physical processors. The processors do not share memory or a

We can view an operating system as a resource allocator. Explain. We can outlook an operating system as a resource allocator. A computer system has Many resources (software and

what is deadlock

Q. Remapping of bad blocks by sector sparing or else sector slipping could influence performance. Presume that the drive in Subsequent Exercise has a total of 100 bad sectors at r