klarz
klarz

Reputation: 33

Reentrant Lock - possible outputs?

given lock situation:

enter image description here

I think I got this right but I need to be sure so I'm asking you guys if I made a mistake.

I got two possible outputs for variables "x" and "y" in this programm:

1. Lines 1.1 - 1.7: y = 5,
   Lines 2.1 - 2.3: x = 15.

2. Lines 2.1 - 2.3: x = 11,
   rest             y = 25.

are there any other outputs in this exact situation?

Upvotes: 0

Views: 70

Answers (1)

Kenny Hung
Kenny Hung

Reputation: 442

The lock block on the right had side can occur in one of three places:

  • Before 1.1
  • Between 1.3 and 1.5
  • After 1.7

The values of x and y for these three cases are

  • x = 11, y = 25
  • x = 11, y = 5
  • x = 15, y = 5

Upvotes: 1

Related Questions