spinlock model: Simplify state-space
[userspace-rcu.git] / 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 atomic{ !lock -> lock = 1}
25 }
26
27 inline spin_unlock(lock)
28 {
29 lock = 0;
30 }
31
32 proctype proc_X()
33 {
34 do
35 :: spin_lock(lock);
36 refcount = refcount + 1;
37 refcount = refcount - 1;
38 spin_unlock(lock);
39 od;
40 }
41
42 init
43 {
44 run proc_X();
45 run proc_X();
46 }
This page took 0.032731 seconds and 4 git commands to generate.