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 services provided by the operating systems?  Program Development It provides a variety of services and facilities, such as debuggers and editor, to help the

draw a state diagram showing the transissions of a process from creation to termination

What is a semaphore? A semaphore 'S' is a synchronization tool which is  an integer value that, apart from initialization, is accessed only by two standard atomic operations; w

Explain in detail about ipc in linux

General graph directory The serious problem with using an acyclic-graph structure is ensuring that there are no cycles. When we insert links to an existing tree-structured dire

KERNEL ACTIVITY FOR ULTS: The kernel isn't aware of thread activity but it is still managing process activity. When a thread compose a system call the whole process will be bl

Write a note about Directory structure with examples. The FreeBSD directory hierarchy is basic to obtaining an overall understanding of the system. The most significan

The term Operating System (OS) is often misused. It is common, for example, for people to speak of an OS when they are in fact referring to an OS and to a set of additional applica

Define CPU scheduling. CPU scheduling is the method of switching the CPU among several processes. CPU scheduling is the basis of multiprogrammed operating systems. By switching

Q. Explain a mechanism by which one segment could belong to the address space of two different processes. Answer: Because segment tables are a collection of base-limit register