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
Select the correct answer.
Dvinal [7]

Answer:

A

Explanation:

because when you make a presentation so you are already use technology

4 0
3 years ago
What is the difference between "call by value" and "call by reference"? Explain with example in c language.
Serjik [45]

Answer:

<u>Call by reference</u>

In an function if the variables are passed as reference variables this means that the variables are pointing to the original arguments.So the changes made in the function on the reference variables will be reflected back on the original arguments.

For example:-

#include<stdio.h>

void swap(&int f,&int s)

{

   int t=f;

   f=s;

  s =temp;  

}

int main()

{

int n,m;

n=45;

m=85;

swap(n,m);

printf("%d %d",m,n);

return 0;  

}

the values of m and n will get swapped.  

<u> Call by value</u>

In this program the values of m and n will not get swapped because they are passed by value.So duplicate copies of m and n will be created and manipulation will be done on them.

#include<stdio.h>

void swapv(int f,int s)

{

   int t=f;  

   f=s;  

   s=temp;

}

int main()

{  

int n,m;

n=45;

m=85;

swapv(n,m);

printf("%d %d",n,m);

return 0;

}

7 0
3 years ago
The slide layout has placeholders for text, charts, and tables. true or false.
Ksju [112]
The answer to this is true
3 0
3 years ago
Read 2 more answers
TRUE OR FALSE! A query can have no more than three common interpretations.
Vanyuwa [196]

A query can have no more than three common interpretations is false. A query is a search through a source to find the answer to something. A common interpretation are the items that pop up in in the first spots of the search query because they are the most relatable to the question. A common interpretation usually answers the question, but there are times that the question is more complex and needs to be search for longer within the sources that pop up.

8 0
3 years ago
How to change the size of my document in cs6?
Aleonysh [2.5K]
When you're saving your image, it will ask you what quality of the image you want to use and it will show you that you're using a larger or smaller filesize depending on the quality of the image your saving.

<TIP>  Make a duplicate layer before saving the image and uncheck the original. Always save the CS6 file too to re-edit later if need be. But that way you will have the file size you want and the original image is preserved
5 0
3 years ago
Other questions:
  • What is a critique of the feature detector model of object recognition?​?
    8·1 answer
  • Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
    8·1 answer
  • What occurs when you call a method on a reference variable that contains null? Select one: a. An ArrayIndexOutOfBoundsException
    11·1 answer
  • Someone asks you for help with a computer that hangs at odd times. You turn it on and work for about 15 minutes, and then the co
    7·1 answer
  • What is a sign of the brick and mortar and the virtual world meeting together?
    14·1 answer
  • What are the different ways to represent compounds? Check all that apply. a structural formula a ball model a space-filling mode
    13·2 answers
  • Science can give us
    5·2 answers
  • Create html code showing heading tags​
    6·1 answer
  • Mention and explain various alignment options​
    9·1 answer
  • Evaluate and compare free and commercial versions of the Avast antivirus software
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!