subject

Assume we have two threads each running its own code but sharing a variable counter from their parent shared data. Also, assume a uniprocessor system is used. Counter=0

//Thread 1 //Thread 2
for (i=0; i< 10; i++)
{
counter = counter +1;
}
for (j=0; j < 10, J++)
{
counter = counter + 1;
}

1. Prove that there is a race condition in the above example. (10 marks)
2. What is the possible maximum value of variable counter when both threads terminate normally? Show how you calculated that value. (4 marks)
3. Solve the race condition problem above by modifying the code using the Test-and-Set instruction. (6 marks)

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:50, brennarfa
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, elsauceomotho
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
image
Computers and Technology, 24.06.2019 21:30, Xghoued2056
Aobject is used for displaying the results of a question based on stored data. a. query b. report c. table d. form
Answers: 2
image
Computers and Technology, 25.06.2019 03:30, kalithekittenqueen
All nate specialties are offered at two levels, a. journeyman and master. b. installation and service. c. apprentice and journeyman. d. heating and air conditioning.
Answers: 1
You know the right answer?
Assume we have two threads each running its own code but sharing a variable counter from their paren...

Questions in other subjects:

Konu
English, 03.12.2020 01:00
Konu
Mathematics, 03.12.2020 01:00