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 :
33 * futex_wake = (futex == -1 ? 0 : 1); (atomic)
34 * while (futex_wake == 0) { };
39 * if queue = 1, then !_np
41 * By testing progress, i.e. [] <> ((!np_) || (!queue_has_entry)), we
42 * check that we can never block forever if there is an entry in the
45 * The waker performs only 2 loops (and NOT an infinite number of loops)
46 * because we really want to see what happens when the waker stops
49 * This program is free software; you can redistribute it and/or modify
50 * it under the terms of the GNU General Public License as published by
51 * the Free Software Foundation; either version 2 of the License, or
52 * (at your option) any later version.
54 * This program is distributed in the hope that it will be useful,
55 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 * GNU General Public License for more details.
59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software
61 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
63 * Copyright (c) 2009 Mathieu Desnoyers
66 #define get_pid() (_pid)
72 active [2] proctype waker()
74 assert(get_pid() < 2);
98 #ifdef INJ_QUEUE_NO_WAKE
100 queue[get_pid()] = 1;
105 active proctype waiter()
114 :: (queue[0] == 1 || queue[1] == 1) ->
137 :: (futex_wake == 0) ->
147 progress: /* Progress on dequeue */