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 should you do if your computer keeps shutting down while working?
Oliga [24]
D is the best answer hope this help my love

5 0
3 years ago
Read 2 more answers
Which CIDR network has the smallest possible number of hosts? a. 123.0.0.0/8 b. 123.45.0.0/16 c. 123.45.67.0/24 d. All have the
Lina20 [59]

Answer:

CIDR is based on a variable-length subnet masking technique, which allows a new method of representation for IP addresses. Routing prefix is written with a suffix number of bits of the name, such as 123.0.0.0/8, as the CIDR network has the smallest possible amount of hosts.

Explanation:

CIDR ( Class Inter-Domain Routing ) It is a method that is allocating IP addresses and routing the IP. CIDR is introduced in 1933 and replace the architecture of network design on the internet. CIDR slows down the growth of the routing across the web and helps to slow the IP addresses such as IPv4 addresses.

CIDR consists of two groups of bits in the address. In the new age, the network prefix identifies the whole network. This is used as the basis of routing between IP networks and allocation policies.

IPv4 in-network prefix is 8-bit groups.

A typical IPv4 address is 192.168.0.5 the lowest value is 0, and the highest value is 255

In the given choices, 123.0.0.0 / 8 of the possible smallest number of hosts.

8 0
3 years ago
Create an java application that will process 3-digit numbers as follows:
alisha [4.7K]

Answer:

I dont not not the frsidjkbzxc.n bzl,b vbsv,gcjdvc,

Explanation:

5 0
2 years ago
A technician has been notified of a problem on the network. After investigation, the technician determines that a specific inter
bogdanovich [222]

Answer:

Virus is a type of malware which is used in this case.

Explanation:

7 0
3 years ago
Write the name of the tab, the command group, and the icon that you need to use to justify
Dafna11 [192]

Answer:

Tab: Home Tab

Command Group: Paragraph

Icon: Justify Icon

<em>The icon has no name; rather it is represented by 4 horizontal lines that are aligned on both edges</em>

<em />

Explanation:

To answer this question, I'll make use of the following attachment

<em>Where</em>

<em>1- represents the home tab</em>

<em>2 - represents the paragraph</em>

<em>3 - represents the justify icon</em>

<em />

3 0
3 years ago
Other questions:
  • Which is a function of network media?
    14·2 answers
  • By applying styles formats are being applied ?
    14·2 answers
  • Write a program that converst the temperature from Celcius to Fahrenheit. The formula is: F (9/5)C+32
    12·2 answers
  • This is important I need help please
    14·1 answer
  • What conversion factor should be used to convert from meters to Gigameters?
    7·1 answer
  • write the program or pseudocode algorithm that computes the product and average of three integers and display the results​
    7·1 answer
  • What is the purpose of a report?
    12·2 answers
  • A rectangle indicates a single process.true or false​
    7·2 answers
  • Pie charts are best used for
    5·1 answer
  • Computers that are joined together are called networks true or false
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!