1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
barxatty [35]
3 years ago
6

Playville is a tiny town in fictional middle earth, which is inhabited by dwarves and elves. Playville has a playground to which

dwarves and elves go if they wish to play. The sporting rules of Playville state that a play can take place only if either there are 5 dwarves or 3 elves present to play. If the playing condition is not met (i.e., 5 dwarves or 3 elves are not present at the playground), an arriving person (dwarf or elf) has to wait in their respective waiting area near the playground. When either the dwarves or the elves have their quorum, they move on to the playground to play, if the playground is already not in use. The playground, at any time, is either empty or it is occupied by playing dwarves or it is occupied by playing elves.
After a dwarf or elf team has played to its satisfaction, it leaves the ground. Assume all dwarves are identical to each other, and all elves are identical to each other too.

a. Assuming dwarves and elves to be concurrent processes, and using P and V operations, devise an algorithm for each type of process.
b. Is your solution correct?
c. Discuss possibly what you could do to improve your solution.
Computers and Technology
1 answer:
dsp733 years ago
7 0

Answer:

See explaination

Explanation:

function DWARVES()

{

num(dwarves) = num(dwarves)+1;

while (num(dwarves)!=5) ;

P(Ground)

Critical Section code;

V(Ground)

num(dwarves) = 0;

}

Function ELVES()

{

num(Elves) = num(Elves) + 1;

if(num(Elves) ! =5);

P(Ground)

Critical section code;

V(Ground)

num(Elves) = 0

}

Algo Explained -

We have two functions in this algo. First one is for Dwarves and second one is for elves. When any Dwarve execute it goes to its function increment number of dwarves and wait in a loop created by while loop untill number of dwarves become equal to 5 . If number of dwarf become equal to 5 it tries to enter into critical section of code . P(ground) means obtainig lock on ground . and V(Ground) means releasing that lock. If dwarves are using the grond means they are executing the critical section then untill they execute the critical section no Elves should execute critical section. For that binary semaphores or mutexes has been used . Similarly function Elves is implemented

ii) This algorithm should work fine. But If we get a situation like when dwarves are executing the critical section and got preempted before releasing the locks then there may arise a condition of starvation for Elves . Starvation is a case of longer waiting deadlock is a case of infinite waiting.

iii) So to improve our code we can add some timer so that after that each of dwarves or Elves should release the ground .

You might be interested in
What are the uses of a modem
Vlada [557]

Modem provides internet, WiFi, we can connect multiple devices to internet through modem.

Modem provides radiation of short wavelength and the transmitter in your mobile phones and computers convert those radiations into digital signals and vice-versa.

5 0
3 years ago
What is contained in the Open Files section of Shared Folders? ​
amm1812

Answer:

The contents of shared folders might include both programs and data files. Common files may be stored and accessed using shared application folders, which simplify administration and offer a single area for users to store and access common data. If all data files are consolidated in a single shared folder, users will have an easier time finding them.

Explanation:

Hope it helps:)

8 0
2 years ago
Which of these statements about digital media is NOT accurate?
DIA [1.3K]

Answer:

It is any information that is audio or video but not text.

Explanation:

5 0
2 years ago
Some of the latest smartphones claim that a user can work with two apps simultaneously. This would be an example of a unit that
SIZIF [17.4K]

Answer:

MULTITASKING OS

Explanation:

MULTITASKING OPERATING SYSTEM is an operating system that enables and allow user of either a smartphone or computer to make use of more that one applications program at a time.

Example with MULTITASKING OPERATING SYSTEM smartphones user can easily browse the internet with two applications program like chrome and Firefox at a time or simultaneously

Therefore a user working with two apps simultaneously is an example of a unit that uses a MULTITASKING OS.

3 0
2 years ago
What was the original intention for the creation of ARPANET?
Anika [276]

ARPANET was the network that became the 'basis' for the Internet. It was based on a concept first published in 1967. It was developed under the direction of the U.S. Advanced Research Projects Agency (ARPA). In 1969, the idea became a modest reality with the interconnection of four university computers.

3 0
2 years ago
Read 2 more answers
Other questions:
  • Choose the type of critical thinking demonstrated in the example:
    8·2 answers
  • Select the correct answer.
    12·2 answers
  • Which director has shot a movie in HD? George Lucas, Michael Mann, Michael Moore, none of the above, all of the above
    14·1 answer
  • List 5 anti-virus products currently in use
    15·1 answer
  • Click on the _____ tab on the ribbon to open the backstage view.
    7·1 answer
  • Imagine a network with two routers that are connected with a point-to-point HDLC serial link. Each router has an Ethernet, with
    9·1 answer
  • Write a function named reverse_list that takes as a parameter a list and and reverses the order of the elements in that list. It
    12·1 answer
  • There is a file of a few Sean Connery movies on the internet. Each entry has the following form:
    9·1 answer
  • Your company decided to upgrade the older office Ethernet network and needs the fastest speed possible but has decided against f
    8·1 answer
  • HELP FAST PLEASE
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!