A data structure call the gold pile and d gold-diggers

Assignment Help Operating System
Reference no: EM13166784

Consider a computer game that is played as follows. You have G gold-makers each of which at random times produce one unit of gold and adds it to a data structure call the goldpile and D gold-diggers each of which can grab one unit of gold from the goldpile. The amount of gold that can be produced and available for digging can be arbitrarily large. Consider the following functions to be used in goldworld. Does it work correctly if run with multiple diggers and makers? Explain why or why not? If not, identify as many issues as you can. Focus on issues of how mutual exclusion is handled.

semaphore Y=1;
semaphore X=0;

void goldmaker()
{
while (true)
{
Wait a random amount of time.
Make one unit of gold.
semWait(Y);
Add the unit of gold to the goldpile;
semSignal(X);
semSignal(Y);
}
}

void golddigger()
{

While (true)
{
semWait(Y);
semWait(X);
take one unit of gold off the goldpile;
semSignal(X);
}
}

 

 

Reference no: EM13166784

Questions Cloud

Three-process 4 resource system : Give an example of a three-process 4 resource system that is in an unsafe state. Explain why it is in an unsafe state. How many more resources would need to be added to make it a safe state?
Define equation for your preparation of acetyl chloride : Write an equation for your preparation of acetyl chloride
State a silver strip was dipped into the test solution : A test solution contained 2 mL of 0.10 M Ag+. A silver strip was dipped into the test solution, and a cell potential of 0.0592 V was measured against an Ag/Ag+(1.0M) reference half-cell.
Which buffer component must be added and what quantity : A buffer solution is prepared by dissolving 1.50g each of benzioc acid C6H5CO2H and sodium benzoate NaC6H5CO2 in 150.0mL of solution.
A data structure call the gold pile and d gold-diggers : Consider a computer game that is played as follows. You have G gold-makers each of which at random times produce one unit of gold and adds it to a data structure call the goldpile and D gold-diggers each of which can grab one unit of gold from the go..
Evaluate the comment by the accountant of har : Evaluate the comment by the accountant of HAR in respect of the deductibility of expenses and outgoings under Hong Kong salaries tax and profits tax.
Explain what is the enthalpy of combustion of fuel : What is the enthalpy of combustion of this fuel in kJ/mol? The specific heat capacity of water is 4.184 J/g-°C.
If the sum or product of two positive integers : In C++, the largest int value is 2147483647. So, an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect.
Propose a mechanism for the acid-catalyzed synthesis : Propose a mechanism for the acid-catalyzed synthesis of 4,5-dimethyldioxolane + water from formaldehyde

Reviews

Write a Review

Operating System Questions & Answers

  Identifying wireless network architectures

Some of the local hospital's administrators are questioning privacy of patients' data with wireless transmission. Discuss and determine the merits of their concerns.

  Formulate the linear programming model for this problem

Formulate the linear programming model for this problem Plot a graph indicating and labelling clearly all the constraints, the feasible region (R) and the optimal point (X)

  Page frames for public use and seven-page program

Given that main memory is consisted of three page frames for public use and that seven-page program (with pages a, b, c, d, e, f, g) requests pages in the following order: a, b, a, c, d, a, e, f, g, c, b, g.

  Write the send and receive primitives for stated processes

Write the send and receive primitives for stated processes and processes can communicate with each other by name along with message. You need to Identify what type of IPC is this?

  What are some ways to integrate linux servers

What are some ways you could integrate Linux servers into a Windows network to share information? What would be the advantages and disadvantages?

  Describe the concept of a signal

Assume when a child process is forked, a parent may wait for the successful completion of the child via the wait service so that return result of that application can be read from the procedure descriptor block.

  Determine the average seek time of traversed disk

Traversed Disk receives request to access random sector on random track. Suppose head starts at track 0. Determine the average seek time?

  Relocation hardware costs money

Since relocation hardware costs money, why support relocation? Give at least two reasons? 2) Make arguments for smaller page size on a paging system?

  Effects of spyware and adware

Describe the effects of spyware and adware. Discuss how has spyware and adware impacted the public's confidence in the security of internet?

  Pplying the four necessary conditions for deadlock

Assume a multithreaded application uses onlyreader-writer locks for synchronization. Applying the four necessary conditions for deadlock, is deadlock still possibleifmultiple reader-writer locks are used?

  Ethical issues of web site design

Analyze the user interaction interface of a typical website that you might wish to improve and design in terms of any ethical considerations that might require to be addressed.

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

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