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
7.
shusha [124]

Answer:

The answer is "4".

Explanation:

In this code, on line number 4, it will give the error message, and its correct solution can be defined as follows:

In this code, a variable "score" is declared, that holds a value that is 0, and in the next step, a method "onEvent" is declared that uses a method, and in the if block, it checks the "score" value that is less than 5 and it will print the message.

8 0
3 years ago
Your corporation hosts a Web site at the static public IP address 92.110.30.123.
ladessa [460]

Answer:

Check the explanation

Explanation:

In line with the question, we can now derive that:

The router's outside interface IP address will be 92.110.30.65.

The router's inside interface IP address will be 192.168.11.254.

The Web site's IP public IP address will be 92.110.30.123.

The private IP address of the backup Web server will be 192.168.11.110.

and when we say IP address, it stands for Internet Protocol, it is a set of usual predefined rules which are utilized to administrate the manner to which data packets are sent over the internet. An IP address, which is typically just identified as an IP, is a sequence of figures used to uniquely recognize a computer/device on a particular network or on the internet space.

7 0
3 years ago
Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non-negative" otherwise.
taurus [48]

Answer:

The modified program is as follows:

user_val = int(input())

cond_str = 'non-negative'  

if user_val < 0:

   cond_str = 'negative'  

print(user_val, 'is', cond_str)

Explanation:

This gets input for user_val

user_val = int(input())

This initializes cond_str to 'non-negative'

cond_str = 'non-negative'

If user_val is less than 0

if user_val < 0:

cond_str is updated to 'negative'

   cond_str = 'negative'  

This prints the required output

print(user_val, 'is', cond_str)

4 0
3 years ago
Question 55 :You use a computer named Wkst1 on a TCP/IP network, which is installed with an application that uses UDP to send a
liubo4ka [24]

Answer:

The protocol will drop the packets

The application will automatically re-transmit the packets

Explanation:

Based on design, the routers will drop the packets as allowed by the Internet Protocol, due to the collision that resulted from the router being busy and the network is congested or that the packet is corrupt as indicated by the check sequence of the Ethernet frame or the IPv4 header checksum

Given that the application uses User Datagram Protocol (UDP) which does not allow recovery of lost packets, but have their defined methods of overseeing lost packets, as such the application will re-transmit the packet.

4 0
3 years ago
When there is a limited amount of a product, such as rare art or collectible
babunello [35]
C. Scarcity
This is because the word scarce means something is hard to come across or find and there is an insufficient amount for the demand
7 0
3 years ago
Other questions:
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • Which consumer document is most likely to help you if you have trouble figuring out how to operate a device
    6·1 answer
  • Which version of Windows was considered an operating environment rather than an operating system?
    14·1 answer
  • What is the difference between 1080p and 2k?
    14·1 answer
  • What process improves the life of a computer
    11·1 answer
  • Which function would you use to make sure all names are prepared for a mailing label?
    10·2 answers
  • Olivia is trying to save for a new laptop computer. To help her save, she should start a _____. database financial statement per
    7·2 answers
  • What is the difference between Notepad and WordPad?is one more adavnced?if so which one or Notepad is the Mac equivalent of Word
    7·1 answer
  • Lil fun question : burgers or pizza??
    6·2 answers
  • Which memory can be removed from motherboard? RAM OR ROM?​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!