subject

Race conditions are possible in many computer systems. consider an online auction system where the current highest bid for each item must be maintained. a person who wishes to bid on an item calls the bid(amount) function, which compares the amount being bid to the current highest bid. if the amount exceeds the current highest bid, the highest bid is set to the new amount. this is illustrated below:

double amount = 0.0;

void bid(double amount) {

if (amount > highestbid)

highestbid = amount;

}

describe how a race condition is possible in this situation (you may describe it with some scenario)?

what might be done to prevent the race condition from occurring? (you may just modify the code using "acquire()" and "release()" statements)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges"what's being bought" are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them"for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s . so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of events"s of length m and s of length n, each possibly containing an event more than once"and decides in time o(m + n) whether s is a subsequence of s.
Answers: 3
question
Computers and Technology, 22.06.2019 14:30
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
You know the right answer?
Race conditions are possible in many computer systems. consider an online auction system where the c...
Questions
question
Mathematics, 15.07.2019 02:00
question
Mathematics, 15.07.2019 02:00
question
Mathematics, 15.07.2019 02:00
question
Mathematics, 15.07.2019 02:00
question
Mathematics, 15.07.2019 02:00
question
Mathematics, 15.07.2019 02:00
Questions on the website: 13722360