/* begincopyright Copyright (c) 1988 Xerox Corporation. All rights reserved. Use and copying of this software and preparation of derivative works based upon this software are permitted. Any distribution of this software or derivative works must comply with all applicable United States export control laws. This software is made available AS IS, and Xerox Corporation makes no warranty about the software, its performance or its conformity to any specification. Any person obtaining a copy of this software is requested to send their name and post office or electronic mail address to: PCR Coordinator Xerox PARC 3333 Coyote Hill Rd. Palo Alto, CA 94304 endcopyright */ /* * ThreadsSignalsPrivate.h * * Demers, February 26, 1990 4:58:54 pm PST * Boehm, October 29, 1992 2:17:14 pm PST * * Unix signal definitions for VPs and IOPs */ #ifndef _XR_THREADS_SIGNALS_PRIVATE_ #define _XR_THREADS_SIGNALS_PRIVATE_ 1 #ifndef NSIG # include #endif /* * For each interrupt (Unix signal) we provide: * * A Unix signum to send to generate the interrupt: * * XR_SIG_XXX * * A list of Unix signals to be interpreted as this interrupt when received: * * XR_XXX_SIGS * * Indication whether this interrupt is disabled by other handlers: * * XR_XXX_HELD * * Indication that this interrupt is handled on separate stack in the VP's: * * XR_XXX_ONSTACK * * Interrupt handler procedure: * * extern int XR_XxxSigHandler(); * * Initialization proc for handler: * * extern void XR_XxxSigHandlerInit( installed ); * bool installed; * * This is called twice - * before installation of the sigHandler (with installed == FALSE) * after installation of the sigHandler (with installed == TRUE) */ extern void XR_NullSigHandlerInit(/* installed */); /* does nothing */ /* * Resched * * The general paradigm is to store some state and then wake up * a processor by sending it a resched signal, at which point * it notices the stored state and acts on it. * Held by other sigHandlers. * * IOP: * Runs on ordinary stack -- but it's the Unix stack, which * is grown automatically, so no stack overflow worries. * This is how orders are passed to the IOP. * * VP: * Runs on ordinary (process) stack, so it must be careful about * stack overflow. * Often results in a thread switch. */ #define XR_SIG_RESCHED SIGUSR1 #define XR_RESCHED_SIGS { SIGUSR1, 0 } #define XR_RESCHED_HELD TRUE #define XR_RESCHED_ONSTACK FALSE extern void XR_ReschedSigHandler(); #define XR_ReschedSigHandlerInit XR_NullSigHandlerInit /* * Memerr * * Stack overflow, segmentation violation, etc. * Not held by other sigHandlers. * * IOP: * Panic * * VP: * Runs on sigHandler stack. */ #define XR_SIG_MEMERR SIGBUS #define XR_MEMERR_SIGS { SIGBUS, SIGSEGV, 0 } #define XR_MEMERR_HELD FALSE #define XR_MEMERR_ONSTACK TRUE extern void XR_MemerrSigHandler(); #define XR_MemerrSigHandlerInit XR_NullSigHandlerInit /* * Traps * * Floating point exceptions, etc. * Not held by other sigHandlers. * * IOP: * Panic * * VP: * Runs on ordinary (thread) stack. * The sigHandler typically never returns; it just translates the trap * to a Mesa ERROR. This may eventually cause stack overflow, which * get caught in the normal way ... BUT it CAN return, thus must * run on ordinary stack. * If it occurs inside another sigHandler, it should Panic */ #define XR_SIG_TRAP SIGFPE #define XR_TRAP_SIGS { SIGTRAP, SIGIOT, SIGEMT, SIGFPE, 0 } #define XR_TRAP_HELD FALSE #define XR_TRAP_ONSTACK FALSE extern void XR_TrapSigHandler(); #define XR_TrapSigHandlerInit XR_NullSigHandlerInit /* * Illegal ops * * Illegal stack, illegal instruction, privileged instruction, illegal trap * Not held by other sigHandlers. * * IOP: * Panic * * VP: * Runs on handler stack. * If it occurs inside another sigHandler, it should Panic */ #define XR_SIG_ILL SIGILL #define XR_ILL_SIGS { SIGILL, 0 } #define XR_ILL_HELD FALSE #define XR_ILL_ONSTACK TRUE extern void XR_IllSigHandler(); #define XR_IllSigHandlerInit XR_NullSigHandlerInit /* * termination / exit -- used to shut down the XR world */ #define XR_SIG_EXIT SIGTERM #define XR_EXIT_SIGS { SIGTERM, 0 } #define XR_EXIT_HELD TRUE #define XR_EXIT_ONSTACK FALSE extern void XR_ExitSigHandler(); #define XR_ExitSigHandlerInit XR_NullSigHandlerInit /* * Child termination -- used by UIO IOP for Spawn */ #define XR_SIG_CHILD SIGCHLD #define XR_CHILD_SIGS { SIGCHLD, 0 } #define XR_CHILD_HELD TRUE #define XR_CHILD_ONSTACK FALSE extern void XR_ChildSigHandler(); #define XR_ChildSigHandlerInit XR_NullSigHandlerInit /* * Urgent data -- used by UIO IOP for network streams */ #define XR_SIG_URGENT_DATA SIGURG #define XR_URGENT_DATA_SIGS { SIGURG, 0 } #define XR_URGENT_DATA_HELD TRUE #define XR_URGENT_DATA_ONSTACK FALSE extern void XR_UrgentDataSigHandler(); #define XR_UrgentDataSigHandlerInit XR_NullSigHandlerInit /* * Alarm * * "Hardware" clock. * * Runs on handler stack. * If the timeout queue is nonempty, set sa_doTimeouts and request * resched for lowest priority processor. */ #define XR_SIG_ALARM SIGALRM #define XR_ALARM_SIGS { SIGALRM, 0 } #define XR_ALARM_HELD TRUE #define XR_ALARM_ONSTACK TRUE extern void XR_AlarmSigHandler(); extern void XR_AlarmSigHandlerInit(/* installed */); /* * Interrupts for DebugTool * * The INTR signal is just passed to ThreadsDebugTool. * The TTIN signal tells the stdio module that the tty got preempted by * ThreadsDebugTool. */ #define XR_SIG_INTR SIGINT #define XR_INTR_SIGS { SIGINT, SIGQUIT, 0 } #define XR_INTR_HELD TRUE #define XR_INTR_ONSTACK TRUE extern void XR_IntrSigHandler(); #define XR_IntrSigHandlerInit XR_NullSigHandlerInit #define XR_SIG_TTIN SIGTTIN #define XR_TTIN_SIGS { SIGTTIN, 0 } #define XR_TTIN_HELD TRUE #define XR_TTIN_ONSTACK TRUE extern void XR_TtinSigHandler(); #define XR_TtinSigHandlerInit XR_NullSigHandlerInit /* * Interrupts that should get default handlers */ #define XR_DEFAULTED_SIGS { SIGTSTP, SIGCONT, 0 } /* * Size of per process signal stack */ #define XR_SIG_STACK_SIZE (8*1024) #define XR_SIG_STACK_ALIGNMENT 8 /* * Utilities */ extern void XR_InstallSigHandlers (); /* Install handlers for all interrupts. Called after differentiating between vps and iops. It's the responsibility of each handler to do the right thing as a function of what kind of processor it's running on. */ extern void XR_SigStack(/* onStack */); /* bool onStack; Assert we're running on handler stack (onStack == TRUE) or not. */ typedef unsigned XR_SignalState; extern XR_SignalState XR_DisableSignals (); /* Mask signals for critical section. Return previous signal state. */ extern XR_SignalState XR_EnableSignals (); /* Enable signals. Return previous signal state. */ extern XR_SignalState XR_SetSignalState (/* XR_SignalState state */); /* Set specified signal state. Return previous signal state. */ extern void XR_WaitForSignal (); /* Atomically enable all signals and wait for one. */ /* * t_Errno locking * * Used in handlers (so per-thread errno value isn't trashed * by asynchronous signals) */ #define XR_LockErrno() XR_currThread->t_errnoLock += 1 #define XR_UnlockErrno() XR_currThread->t_errnoLock -= 1 #endif _XR_THREADS_SIGNALS_PRIVATE_