2
* Copyright 2000, International Business Machines Corporation and others.
5
* This software has been released under the terms of the IBM Public
6
* License. For details, see the LICENSE file in the top-level source
7
* directory or online at http://www.openafs.org/dl/license10.html
10
/*******************************************************************\
12
* Information Technology Center *
13
* Carnegie-Mellon University *
15
\*******************************************************************/
16
#include <afsconfig.h>
17
#include <afs/param.h>
19
RCSID("$Header: /afs/sipb.mit.edu/project/openafs/debian/cvs/openafs/src/lwp/preempt.c,v 1.1.1.12 2002/09/26 19:06:55 hartmans Exp $");
22
#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_DJGPP_ENV)
27
#ifdef HAVE_UCONTEXT_H
33
#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
34
int PRE_Block = 0; /* used in lwp.c and process.s */
36
char PRE_Block = 0; /* used in lwp.c and process.s */
39
#if HAVE_SIGACTION && defined(SA_SIGINFO)
40
static void AlarmHandler(sig, st, scp)
45
static void AlarmHandler(sig, code, scp)
47
struct sigcontext *scp;
50
if (PRE_Block == 0 && lwp_cpptr->level == 0)
53
#if HAVE_SIGACTION && defined(SA_SIGINFO)
54
sigprocmask(SIG_SETMASK, &scp->uc_sigmask, NULL);
56
sigsetmask(scp->sc_mask);
58
LWP_DispatchProcess();
64
int PRE_InitPreempt(slice)
65
struct timeval *slice;
68
#if HAVE_SIGACTION && defined(SA_SIGINFO)
69
struct sigaction action;
74
if (lwp_cpptr == 0) return (LWP_EINIT);
78
itv.it_interval.tv_sec = itv.it_value.tv_sec = DEFAULTSLICE;
79
itv.it_interval.tv_usec = itv.it_value.tv_usec = 0;
83
itv.it_interval = itv.it_value = *slice;
86
#if HAVE_SIGACTION && defined(SA_SIGINFO)
87
memset((char *)&action, 0, sizeof(action));
88
action.sa_sigaction = AlarmHandler;
89
action.sa_flags = SA_SIGINFO;
91
if ((sigaction(SIGALRM, &action, (struct sigaction *)0) == -1) ||
92
(setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1))
95
memset((char *)&vec, 0, sizeof(vec));
96
vec.sv_handler = AlarmHandler;
97
vec.sv_mask = vec.sv_onstack = 0;
99
if ((sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1) ||
100
(setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1))
109
struct itimerval itv;
110
#if HAVE_SIGACTION && defined(SA_SIGINFO)
111
struct sigaction action;
116
if (lwp_cpptr == 0) return (LWP_EINIT);
118
itv.it_value.tv_sec = itv.it_value.tv_usec = 0;
120
#if HAVE_SIGACTION && defined(SA_SIGINFO)
121
memset((char *)&action, 0, sizeof(action));
122
action.sa_handler = SIG_DFL;
124
if ((setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1) ||
125
(sigaction(SIGALRM, &action, (struct sigaction *)0) == -1))
128
memset((char *)&vec, 0, sizeof(vec));
129
vec.sv_handler = SIG_DFL;
130
vec.sv_mask = vec.sv_onstack = 0;
132
if ((setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1) ||
133
(sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1))
140
#endif /* AFS_LINUX20_ENV */