hash table comment fix.
[urcu.git] / formal-model / spinlock / mem-progress.spin
CommitLineData
656c7dc1
MD
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (c) 2009 Mathieu Desnoyers
17 */
18
19byte lock = 0;
20byte refcount = 0;
21
22inline spin_lock(lock)
23{
24 do
25 :: 1 -> atomic {
26 if
27 :: (lock) ->
28 skip;
29 :: else ->
30 lock = 1;
31 break;
32 fi;
33 }
34 od;
35}
36
37inline spin_unlock(lock)
38{
39 lock = 0;
40}
41
42proctype proc_A()
43{
44 do
45 :: 1->
46progress_A:
47 spin_lock(lock);
48 refcount = refcount + 1;
49 refcount = refcount - 1;
50 spin_unlock(lock);
51 od;
52}
53
54proctype proc_B()
55{
56 do
57 :: 1->
58 spin_lock(lock);
59 refcount = refcount + 1;
60 refcount = refcount - 1;
61 spin_unlock(lock);
62 od;
63}
64
65init
66{
67 run proc_A();
68 run proc_B();
69}
This page took 0.025167 seconds and 4 git commands to generate.