File: ex_3b.pml

package info (click to toggle)
spin 6.4.5%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,636 kB
  • ctags: 2,878
  • sloc: ansic: 40,035; yacc: 996; makefile: 37; sh: 5
file content (16 lines) | stat: -rw-r--r-- 261 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// http://spinroot.com/spin/Doc/Exercises.html
// Peterson's algorithm, 1981

bool flag[2]
bool turn

active [2] proctype user()
{
	flag[_pid] = true
	turn = _pid
	(flag[1-_pid] == false || turn == 1-_pid)

crit:	skip	// critical section

	flag[_pid] = false
}