Critical Section Review Problems - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Critical Section Review Problems

Description:

Question: Give an execution sequence where the two threads execute concurrently ... while (turn == 1) ; Exit_Mutex: turn = 1; Question: Which two requirements of ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 8
Provided by: srikantat
Category:

less

Transcript and Presenter's Notes

Title: Critical Section Review Problems


1
Critical Section Review Problems
2
Problem 1
  • Thread 1
  • x x1
  • /
  • ld r1,x
  • add r1,1
  • st r1,x
  • /
  • Thread 2
  • x x1
  • /
  • ld r1,x
  • add r1,1
  • st r1,x
  • /

Question Give an execution sequence where the
two threads execute concurrently and the final
value of X is one. Assume that initial value of X
is zero.
3
Problem 2
  • Thread 1
  • Enter_Mutex
  • while (busy 1)
  • busy 1
  • Exit_Mutex
  • busy 0

Thread 2 Enter_Mutex while (busy 1)
busy 1 Exit_Mutex busy 0
Question Give an execution sequence where both
the threads execute concurrently, and the first
thread sets busy 1 and still the second thread
goes past the while loop. busy is initialized
zero.
4
Problem 3
  • Thread 1
  • Enter_Mutexwhile (turn 2)
  • Exit_Mutex
  • turn 2

Thread 2 Enter_Mutexwhile (turn
1) Exit_Mutex turn 1
Question Which two requirements of critical
section solution are violated? Give a scenario
for violations.
5
Problem 4
Question Which of the four requirements for the
critical section solution are violated?
6
Problem 5
Question Which of the four requirements for the
critical section solution are violated?
7
Problem 6
  • TSL R, Lock TSL Test and Set LockR
    register, Lock memory location
  • Atomically (atomic nothing can interfere) -
    Read Lock into R - Store a non-zero value into
    Lock

Question What should be the code to enter the
critical section? Code to exit the critical
section?
Write a Comment
User Comments (0)
About PowerShow.com