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
Travka [436]
3 years ago
14

Race conditions are possible in many computer systems. Consider a banking system with two methods: deposit(amount) and withdraw(

amount). These two methods are passed the amount that is to be deposited or withdrawn from a bank account. Assume that a husband and wife share a bank account and that concurrently the husband calls the withdraw() method and the wife calls deposit(). Describe how a race condition is possible and what might be done to prevent the race condition from occurring.
Computers and Technology
1 answer:
Fittoniya [83]3 years ago
4 0

Answer:

Race Condition is possible if husband and wife both have concurrent functionality.

Explanation:

For eg. if Balance = 3000 and husband withdraws = 1000 then remaining balance is = 2000.

One the other hand if balance is 3000 and wife deposits =1000 then remaining balance is 4000

we can see that there is inconsistency that is not acceptable.

To solve the problem mostly we are using Peterson's Algorithm

Account can be used for husband and wife,

int flag = 0

boolean account

1 :Husband

do{

account[i] =TRUE;

flag=(i+1)%2

while (account [(i+1)%2] && turn =(i+1)%2;

withdraw();

account[i] = FALSE

(remainder)

} While (TRUE);

This process can be repeat with (Wife)  where i will be replaced by j ,i=0 or 1 and j =1 or 0

  • flag identify which is going to access the bank account
  • account make sire that 2 users are mutually exclusive

Proved the race condition is prevented

You might be interested in
Lập trình web truy vấn csdl và hienr thị ra màn hình danh sách các bản ghi
almond37 [142]

Answer:

ExplanatOverfishing occurs "when more fish are caught than the population can replace through natural reproduction," according to the World Wildlife . Once this occurs, the species is no longer "sustainable." Eighty-seven percent of all the world's fish stocks that we know about are at the "breaking point," according to the Environmental Defense Fund (EDF).

ion:

3 0
2 years ago
In Microsoft Exel, graphs are refered to as_________
algol [13]
The answer is charts D since tables are still referred to as tables
4 0
2 years ago
HOW DO I DELETE A BRAINLY QUESTION?
Fantom [35]

Answer:

To delete a question you asked, click the arrow in the top right-hand corner of your question page and select Delete. If any answers have been added to your question, you'll have to request its deletion.Explanation:

8 0
3 years ago
Read 2 more answers
If a computer system does not have a graphics card installed in a motherboard's PCIe slot, which component handles video calcula
Klio2033 [76]

Answer:The Cpu or a chip on the Motherboard

Explanation: yore welcome

5 0
3 years ago
Scientists measure an object’s mass in kilograms and its weight in newtons. If you knowthe amount of mass of an object in kilogr
Phoenix [80]

Answer:

public class WeightCalculator {

   

   private static DecimalFormat df2 = new DecimalFormat("#.##");

   

   public static void main(String args[]){

       //create scanner to receive user input

       Scanner in = new Scanner(System.in);

       //alert user to input mass

       System.out. println("Enter the Mass in Kg");

       //collect the input as a string

       String s = in. nextLine();

       //convert string to double and multiply by 9.8

       Double weight = Double.valueOf(s)* 9.8;

       

       //Print out answer formatted to 2 decimal place

       System.out. println("The Weight is " + df2.format(weight) + "N");

       

       //conditional statement to check if weight is less than 100

       if (weight < 100){

           System.out. println("Oops, it is too light");

       }

       //conditional statement to check if weight is more than 500

       if (weight > 500){

           System.out. println("Oops, it is too heavy");

       }            

   }

}

7 0
3 years ago
Other questions:
  • From the video "Your Password Sucks", using computer power to guess your password by trying multiple variations one after the ot
    15·2 answers
  • Which interest bearing account is best for people who won’t need access to their money for several months or longer?
    6·1 answer
  • As a compositional mode for electronic? media, __________ help people find their way through an unfamiliar system or? subject; t
    7·1 answer
  • Fourlotts Corp. provide integrated services that include storing manufactured goods, packaging, and delivering it to the dealers
    13·1 answer
  • "What is the concept of a computer implemented as part of a larger system that is typically designed around a limited set of spe
    13·1 answer
  • Select the correct answer.
    6·2 answers
  • What are the steps to open the Custom AutoFilter dialog box?
    5·2 answers
  • Which of the following statements is/are correct? a. At the network layer, entitlement can map identity and/or attributes to fun
    8·1 answer
  • Question 2 of 10
    15·1 answer
  • 9- Write a program in MARIE to add three numbers.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!