2 * futex.spin: Promela code to validate n wakers to 1 waiter selective
3 * futex wakeup algorithm.
5 * In this model, waker threads are told whether they are still being
6 * waited on, and skip the futex wakeup if not.
18 * if (this.waiting == 1) {
20 * if (gp_futex == -1) {
31 * waiting |= (queue != gp);
32 * in_registry &= (queue != gp);
33 * if (all in_registry == 0) {
39 * futex_wake = (gp_futex == -1 ? 0 : 1);
40 * while (futex_wake == 0) { }
45 * By testing progress, i.e. [] <> !np_, we check that an infinite sequence
46 * of update_counter_and_wait (and consequently of synchronize_rcu) will
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-2011 Mathieu Desnoyers
66 #define get_pid() (_pid)
73 int in_registry[2] = 0;
75 active [2] proctype waker()
77 assert(get_pid() < 2);
81 queue[get_pid()] = gp;
84 :: (waiting[get_pid()] == 1) ->
85 waiting[get_pid()] = 0;
87 :: (gp_futex == -1) ->
89 #ifndef INJ_QUEUE_NO_WAKE
100 active proctype waiter()
107 #if (!defined(INJ_LATE_DEC) && !defined(INJ_INVERT_WAITING_VS_GP_FUTEX))
111 :: (in_registry[0] == 1 && queue[0] != gp) ->
117 :: (in_registry[1] == 1 && queue[1] != gp) ->
124 :: (in_registry[0] == 1 && queue[0] == gp) ->
130 :: (in_registry[1] == 1 && queue[1] == gp) ->
135 #ifdef INJ_INVERT_WAITING_VS_GP_FUTEX
140 :: (in_registry[0] == 0 && in_registry[1] == 0) ->
151 futex_wake = gp_futex + 1;
155 :: (futex_wake == 0) ->