2 * futex.spin: Promela code to validate futex wakeup algorithm.
14 * if (gp_futex == -1) {
24 * in_registry &= (queue != gp);
25 * if (all in_registry == 0) {
31 * futex_wake = (gp_futex == -1 ? 0 : 1);
32 * while (futex_wake == 0) { }
37 * By testing progress, i.e. [] <> !np_, we check that an infinite sequence
38 * of update_counter_and_wait (and consequently of synchronize_rcu) will
41 * This program is free software; you can redistribute it and/or modify
42 * it under the terms of the GNU General Public License as published by
43 * the Free Software Foundation; either version 2 of the License, or
44 * (at your option) any later version.
46 * This program is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details.
51 * You should have received a copy of the GNU General Public License
52 * along with this program; if not, write to the Free Software
53 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
55 * Copyright (c) 2009 Mathieu Desnoyers
58 #define get_pid() (_pid)
64 int in_registry[2] = 0;
66 active [2] proctype waker()
68 assert(get_pid() < 2);
72 queue[get_pid()] = gp;
75 :: (gp_futex == -1) ->
77 #ifndef INJ_QUEUE_NO_WAKE
87 active proctype waiter()
99 :: (in_registry[0] == 1 && queue[0] == gp) ->
105 :: (in_registry[1] == 1 && queue[1] == gp) ->
111 :: (in_registry[0] == 0 && in_registry[1] == 0) ->
122 futex_wake = gp_futex + 1;
126 :: (futex_wake == 0) ->