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

What are privileged instructions, What are privileged instructions? Som...

What are privileged instructions? Some of the machine instructions that may cause harm to a system are designated as privileged instructions. The hardware permits the privilege

Explain concept of buffering, Buffering Messages exchanged by communica...

Buffering Messages exchanged by communication processes reside in a impermanent queue. Such a queue can be executed in three ways. Zero capacity: The queue length is 0.

Explain the basic concepts of segmentation, Explain the basic concepts of s...

Explain the basic concepts of segmentation. Segmentation definition User view of program Hardware used with diagram-segment table, base, limit & offset Protection and

Explain types of file allocation-contiguous allocation, Contiguous allocati...

Contiguous allocation: Every file will be allocated contiguous space in the memory. Allow the block size be 1K If a 50K files desires to be allocated space after t

Bind a real-time thread to an lwp, Q. Suppose an operating system maps user...

Q. Suppose an operating system maps user-level threads to the kernel utilizing the many-to-many model where the mapping is done through the use of LWPs. In addition the system allo

What are the advantages of contiguous allocation, What are the advantages o...

What are the advantages of Contiguous allocation? The advantages are a. Supports direct access b. Supports sequential access c. Number of disk seeks is minimal.

Control the access of the three global variables, Give a brief introduction...

Give a brief introduction about the operation of your program and show that you understand the idea behind threads and mutual exclusion variable. Why do we need to use mutual exclu

Estimation the number of input - output per second, Q. Remapping of bad bl...

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

Information system can be divided into three task areas, From hardware pers...

From hardware perspective, every information system can be divided into three task areas Presentation, Application Logic and Data Storage. The R/3 Basis software is extremely s

Question 3:, Question 3: (a) Fincorp Ltd is an insurance company wishing t...

Question 3: (a) Fincorp Ltd is an insurance company wishing to change over to a better business system using an improved version of a financial information system (FIS). The direc

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