thread0: x=x+1
thread1: x=x*2
|
thread0: r0=x, inc r0, x=r0
thread1: r1=x, shiftl r1, x=r1
|
1. /* thread0: x=x+1, using r0 */
2. ld x, r0;
3. inc r0;
4. st r0, x;
5. /* END thread0 */
6. /* thread1: x=x*2, using r1 */
7. ld x, r1;
8. shiftl r1;
9. st r1, x;
10 /* END thread1 */
![]() |
1. show int balance = 0; /* A variable shared between all processes. */
2. active proctype deposit()
3. {
4. balance++;
5. }
6. active proctype withdraw()
7. {
8. balance--;
9. }
![]() |
1. show int balance = 0; /* A variable shared between all processes. */
2. active proctype deposit()
3. {
4. show int new_bal;
5. new_bal = balance;
6. new_bal++;
7. balance = new_bal;
8. }
9. active proctype withdraw()
10. {
11. show int new_bal;
12. new_bal = balance;
13. new_bal--;
14. balance = new_bal;
15. }
|