/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef TRIP_H #define TRIP_H #include #include #define SIGCLAIM SIGUSR1 #define SIGYIELD SIGUSR2 #define PRI_HIGH 1 #define PRI_LOW 0 #define CLAIM_SLEEP_TIMER 100000 /* microseconds */ __BEGIN_DECLS extern result claim_line(pid_t, int pri); extern void wait_line(); __END_DECLS #define yield_line(pid) kill(pid, SIGYIELD) /* * MACROS for the standard case */ #define TRIP_DECL bool __init_trip = TRUE #define TRAP_DECL bool __init_trap = TRUE #define __INIT_TRIP_TRAP(cp) \ atsignal(SIGCLAIM, 0) { yield_line(cp); wait_line(); } \ atsignal(SIGYIELD, 0); #define TRIP_INIT(cp) __INIT_TRIP_TRAP(cp) \ if(__init_trip) { __init_trip = FALSE; wait_line(); } #define TRAP_INIT(cp) __INIT_TRIP_TRAP(cp) \ if(__init_trap) { __init_trap = FALSE; sleep(1); yield_line(cp); } #endif