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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
Which of the following statements tests if students have a grade of 70 or above, as well as fewer than five absences? a: if(grade > = 70 and daysabsent < = 5): b: if(grade > = 70 or daysabsent < = 5): c: if(grade > 70 and daysabsent < = 5): d: if(grade > 70 or daysabsent < = 5): i took the test the answer is a
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 23.06.2019 01:00
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan.in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan.out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
question
Computers and Technology, 23.06.2019 05:20
Which operating system is a version of linux?
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
question
English, 22.01.2021 03:10
question
English, 22.01.2021 03:10
question
Social Studies, 22.01.2021 03:10
Questions on the website: 13722363