2 * futex.spin: Promela code to validate n wakers to 1 waiter futex
5 * In this model, waker threads unconditionally wake the waiter if it
6 * needs to be awakened. We guarantee that the waiter will never wait
7 * forever if it needs to be awakened, even if the waker is inactive
8 * after requiring the wakeup.
10 * Algorithm verified :
32 * futex_wake = (futex == -1 ? 0 : 1); (atomic)
33 * while (futex_wake == 0) { };
40 * if queue = 1, then !_np
42 * By testing progress, i.e. [] <> ((!np_) || (!queue_has_entry)), we
43 * check that we can never block forever if there is an entry in the
46 * The waker performs only 2 loops (and NOT an infinite number of loops)
47 * because we really want to see what happens when the waker stops
50 * This program is free software; you can redistribute it and/or modify
51 * it under the terms of the GNU General Public License as published by
52 * the Free Software Foundation; either version 2 of the License, or
53 * (at your option) any later version.
55 * This program is distributed in the hope that it will be useful,
56 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 * GNU General Public License for more details.
60 * You should have received a copy of the GNU General Public License
61 * along with this program; if not, write to the Free Software
62 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
64 * Copyright (c) 2009 Mathieu Desnoyers
67 #define get_pid() (_pid)
73 active [2] proctype waker()
75 assert(get_pid() < 2);
99 #ifdef INJ_QUEUE_NO_WAKE
101 queue[get_pid()] = 1;
106 active proctype waiter()
115 :: (queue[0] == 1 || queue[1] == 1) ->
138 :: (futex_wake == 0) ->
148 progress: /* Progress on dequeue */