X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=ticketlock-testwait%2Frefcount.spin.input;fp=ticketlock-testwait%2Frefcount.spin.input;h=0000000000000000000000000000000000000000;hb=307daf8c9b05b394c48c069083891d6dc14ff345;hp=d2a22d22425f1d65443114337aa77b243557bec5;hpb=08e5a09d6dcc497e88d6f79b9d8c33198c515acd;p=urcu.git diff --git a/ticketlock-testwait/refcount.spin.input b/ticketlock-testwait/refcount.spin.input deleted file mode 100644 index d2a22d2..0000000 --- a/ticketlock-testwait/refcount.spin.input +++ /dev/null @@ -1,114 +0,0 @@ -#define refcount_gt_one (refcount > 1) -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (c) 2009 Mathieu Desnoyers - */ - -/* 16 CPUs max (byte has 8 bits, divided in two) */ - -#ifndef CONFIG_BITS_PER_BYTE -#define BITS_PER_BYTE 8 -#else -#define BITS_PER_BYTE CONFIG_BITS_PER_BYTE -#endif - -#define HBPB (BITS_PER_BYTE / 2) /* 4 */ -#define HMASK ((1 << HBPB) - 1) /* 0x0F */ - -/* for byte type */ -#define LOW_HALF(val) ((val) & HMASK) -#define LOW_HALF_INC 1 - -#define HIGH_HALF(val) ((val) & (HMASK << HBPB)) -#define HIGH_HALF_INC (1 << HBPB) - -byte lock = 0; -byte refcount = 0; - -#define need_pause() (_pid == 1) - -/* - * Test weak fairness by either not pausing or cycling for any number of - * steps, or forever. - * Models a slow thread. Should be added between each atomic steps. - * To test for wait-freedom (no starvation of a specific thread), add do_pause - * in threads other than the one we are checking for progress (and which - * contains the progress label). - * To test for lock-freedom (system-wide progress), add to all threads except - * one. All threads contain progress labels. - */ -inline do_pause() -{ - if - :: need_pause() -> - do - :: 1 -> - if - :: 1 -> skip; - :: 1 -> break; - fi; - od; - :: else -> - skip; - fi; -} - -inline spin_lock(lock, ticket) -{ - atomic { - ticket = HIGH_HALF(lock) >> HBPB; - lock = lock + HIGH_HALF_INC; /* overflow expected */ - } - - do - :: 1 -> - if - :: (LOW_HALF(lock) == ticket) -> - break; - :: else -> - skip; - fi; - od; -} - -inline spin_unlock(lock) -{ - lock = HIGH_HALF(lock) | LOW_HALF(lock + LOW_HALF_INC); -} - -proctype proc_X() -{ - byte ticket; - - do - :: 1-> - spin_lock(lock, ticket); -progress: - refcount = refcount + 1; - do_pause(); - refcount = refcount - 1; - spin_unlock(lock); - od; -} - -init -{ - run proc_X(); - run proc_X(); - //run proc_X(); - //run proc_X(); - //run proc_X(); -}