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

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  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