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

Determine the syntax of the assembler directive equ, Determine the syntax o...

Determine the syntax of the assembler directive EQU The following is syntax of the assembler directive EQU: EQU

Components of an operating system-control programs, CONTROL PROGRAMS Co...

CONTROL PROGRAMS Control Programs are those programs which control & maintain the operation of computer. They provide basic facilities. Control program are further divided into

Total physical memory and total virtual memory , A practical task specified...

A practical task specified in the Study Guide, Computer architecture, was to record your computer's specifications. Submit the data you recorded, which will contain the following d

How free-space is managed using bit vector implementation, How free-space i...

How free-space is managed using bit vector implementation? The free-space list is implemented as a bit map or bit vector. Each block is shown by 1 bit. If the block is free, th

Major locking errors, When programming with threads, there are three very c...

When programming with threads, there are three very common mistakes that programmers often make: 1. locking twice (depending on the system and type of lock, can cause crashes, h

What is demand paging, What is Demand paging? Virtual memory is commonl...

What is Demand paging? Virtual memory is commonly executed by demand paging. In demand paging, the pager brings only those essential pages into memory instead of swapping in a

Defining kernel, Problem 1. What is kernel? What are the main component...

Problem 1. What is kernel? What are the main components of a kernel? Defining Kernel Explaining Main components of Kernel 2. What is mutual exclusion? What are i

How can deadlocks be represented?, How can deadlocks be represented? D...

How can deadlocks be represented? Deadlocks are able to be described in terms of a directed graph called as a system resource-allocation graph. This graph contains of the foll

Write note on process, Write note on process, process state? A process ...

Write note on process, process state? A process is in excess of the program code which is sometimes known as text section. It as well includes the current activity as represent

Execution without entering a deadlock state, Q. Presume that a system is in...

Q. Presume that a system is in an unsafe state. Illustrate that it is possible for the processes to complete their execution without entering a deadlock state. Answer: An unsaf

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