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