Bag of tasks, Operating System

The producer-consumermodel above has a standard human analogy of an assembly line. Humans have specialized skills, however, whereas threads running the same program do not need to be specialized: every thread has access to the same code and data. So any thread could do the work of any other thread.

In the bag of tasks approach, we have a collection of mostly independent "worker threads"; we no longer need to have different types of threads (one for the parser, one for the workers, etc). A bag of tasks system is very simple: every time a worker doesn't have anything to do, it goes to the bag of tasks and gets something to work on; in our web server example, this bag of tasks could contain new connections to be processed.

The advantage of the bag of tasks approach is that we can imagine all workers as being homogeneously implemented, each one running a speci?c piece of code depending on the type of the task it has to process at that time (imagine each worker as being implemented with a big switch statement).

Let us now present a way to convert the pseudo-code for the web server, given in the ?rst section, to a Bag of Tasks style. Assume we have an addWork thread and a bunch of worker threads.

addWork thread(): // only one thread of this type
while(true)
wait connection
bag.put(url)
worker thread(): /// there will be a bunch of these threads
while(true)
url = bag.poll()
look up url contents in cache
if (!in cache)
fetch from disk
put in cache
send data to client

The bag of tasks approach seems to exploit the available parallelism well, and it is easier to program and to extend. It has one major performance drawback, however, namely that there is only one lock protecting the bag; this implies contention. Also, imagine for instance that some of the workers are pretty quick; it could be the case that they acquire the lock, ?nish processing, release the lock, re-acquire it, etc. The problemnow is that each worker would be, itself, a new bottleneck.

 

Posted Date: 3/13/2013 3:06:28 AM | Location : United States







Related Discussions:- Bag of tasks, Assignment Help, Ask Question on Bag of tasks, Get Answer, Expert's Help, Bag of tasks Discussions

Write discussion on Bag of tasks
Your posts are moderated
Related Questions
Question: a) The following refers to optimization under Windows XP: i) Give five steps which could undertake to enhance overall system performance in a default Windows XP in

We are use to using variables within C without thinking about where they are stored. Most variables are dynamic i.e. can change, therefore they are stored in Ram, unlike a program

FIXED PARTITIONING Using fixed partitioning we are able to allocate the memory Here we are dividing the memory into a few fixed partitions.Every partition may not be of the si

explain how indefinite blocking or starvation occurs..

What is parsing Parsing is the procedure of analyzing a text, made of a sequence of tokens, to define its grammatical structure regarding to a given formal grammar. Parsing is

What are the different directory structures? Explain each type. There are five dissimilar directory structures: 1.      Single level directory 2.      Two level directory

Demonstrate that your program (include the program output as part of the final report) can produce the correct output with the following parameters. For each case comment if the ou

Q. Present an algorithm for reconstructing a logical ring after a process in the ring fails? Answer: Typically distributed systems utilize a coordinator process that performs

Explain Formal Language Grammar A formal language grammar is a set of formation rules which explain which strings formed from the alphabet of a formal language are syntacticall

What advantages are there to this two-level directory? Users are isolated from each other. Users have more freedom in choosing file names.