A) identify the race condition. B) assume you have a mutex lock named mutex with
ID: 3789101 • Letter: A
Question
A) identify the race condition. B) assume you have a mutex lock named mutex with the operations aquire() and release(). Indicate where the locking needs to be placed to prevent race conditions. C) could we replace the integer variable Int number of processes =0 With atomic number processes 0 A) identify the race condition. B) assume you have a mutex lock named mutex with the operations aquire() and release(). Indicate where the locking needs to be placed to prevent race conditions. C) could we replace the integer variable Int number of processes =0 With atomic number processes 0 B) assume you have a mutex lock named mutex with the operations aquire() and release(). Indicate where the locking needs to be placed to prevent race conditions. C) could we replace the integer variable Int number of processes =0 With atomic number processes 0Explanation / Answer
a. There is a race condition on the variable number of processes.
b. A call to acquire() must be placed upon entering each function and a call to release() immediately before exiting each function.
c. No, it would not help. The reason is because the race occurs in the allocate process() function where number of processes is first tested in the if statement, yet is updated afterwards, based upon the value of the test. it is possible that number of processes = 254 at the time of the test, yet because of the race condition, is set to 255 by another thread before it is incremented yet again.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.