Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

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.

 

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9528168

Have any Question?


Related Questions in Operating System

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As