Bag of tasks, Operating System

Assignment Help:

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.

 


Related Discussions:- Bag of tasks

Explain the proper distribution of functionality and code, Explain the Prop...

Explain the Proper Distribution of Functionality and Code It is important to note that the bandwidth of the server operating system and server processor availability is fixed.

What is the kernel, What is the kernel? A more common explanation is th...

What is the kernel? A more common explanation is that the OS is the one program running at all times on the computer  usually known as the kernel, with all else being applicati

State in a deadlock-avoidance system, Question: In a deadlock, processe...

Question: In a deadlock, processes never finish executing and system resources are tied up, preventing other jobs from starting. Deadlocks can be characterised by a set of cond

Nested Macro calls, . Nested Macro calls are expanded using the

. Nested Macro calls are expanded using the

Parent process: why not finishing and how to make finish, #include #inclu...

#include #include #include #include #include int main(void) { int pchan[2], pid, rval, cvar; char buf[20]; if (pipe(pchan) == -1){

What is turnaround time, What is turnaround time? Turnaround time is th...

What is turnaround time? Turnaround time is the interval from the time of submission to the time of completion of a process. It is the sum of the periods exhausted waiting to g

What is a client server system, What is a client server system? Central...

What is a client server system? Centralized systems proceed as server systems to satisfy request generated by client systems Server system is able to be broadly div

Explain the different multithreading models, Question 1: a) Briefly exp...

Question 1: a) Briefly explain each of the following terms: (i) Distributed systems. (ii) Real time systems. (iii) Multiprocessor. b) What is the impo

Define a public key encryption system, Define a public key encryption syste...

Define a public key encryption system Allows just the correct receiver to decode the data

What are the disadvantages of linked allocation, What are the disadvantages...

What are the disadvantages of linked allocation? The drawbacks are a. Used only for sequential access of files. b. Direct access is not supported c. Memory space neede

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