Update formal model from local copy
[urcu.git] / formal-model / spinlock / mem.spin
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
19 byte lock = 0;
20 byte refcount = 0;
21
22 inline 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
37 inline spin_unlock(lock)
38 {
39 lock = 0;
40 }
41
42 proctype proc_X()
43 {
44 do
45 :: 1 ->
46 spin_lock(lock);
47 refcount = refcount + 1;
48 refcount = refcount - 1;
49 spin_unlock(lock);
50 od;
51 }
52
53 init
54 {
55 run proc_X();
56 run proc_X();
57 }
This page took 0.033599 seconds and 4 git commands to generate.