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>
25 #if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_DJGPP_ENV)
29 int PRE_InitPreempt(slice)
30 struct timeval *slice;
44 #if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
45 int PRE_Block = 0; /* used in lwp.c and process.s */
47 char PRE_Block = 0; /* used in lwp.c and process.s */
50 #if HAVE_SIGACTION && defined(SA_SIGINFO)
51 static void AlarmHandler(sig, st, scp)
56 static void AlarmHandler(sig, code, scp)
58 struct sigcontext *scp;
61 if (PRE_Block == 0 && lwp_cpptr->level == 0)
64 #if HAVE_SIGACTION && defined(SA_SIGINFO)
65 sigprocmask(SIG_SETMASK, &scp->uc_sigmask, NULL);
67 sigsetmask(scp->sc_mask);
69 LWP_DispatchProcess();
75 int PRE_InitPreempt(slice)
76 struct timeval *slice;
79 #if HAVE_SIGACTION && defined(SA_SIGINFO)
80 struct sigaction action;
85 if (lwp_cpptr == 0) return (LWP_EINIT);
89 itv.it_interval.tv_sec = itv.it_value.tv_sec = DEFAULTSLICE;
90 itv.it_interval.tv_usec = itv.it_value.tv_usec = 0;
94 itv.it_interval = itv.it_value = *slice;
97 #if HAVE_SIGACTION && defined(SA_SIGINFO)
98 memset((char *)&action, 0, sizeof(action));
99 action.sa_sigaction = AlarmHandler;
100 action.sa_flags = SA_SIGINFO;
102 if ((sigaction(SIGALRM, &action, NULL) == -1) ||
103 (setitimer(ITIMER_REAL, &itv, NULL) == -1))
106 memset((char *)&vec, 0, sizeof(vec));
107 vec.sv_handler = AlarmHandler;
108 vec.sv_mask = vec.sv_onstack = 0;
110 if ((sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1) ||
111 (setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1))
120 struct itimerval itv;
121 #if HAVE_SIGACTION && defined(SA_SIGINFO)
122 struct sigaction action;
127 if (lwp_cpptr == 0) return (LWP_EINIT);
129 itv.it_value.tv_sec = itv.it_value.tv_usec = 0;
131 #if HAVE_SIGACTION && defined(SA_SIGINFO)
132 memset((char *)&action, 0, sizeof(action));
133 action.sa_handler = SIG_DFL;
135 if ((setitimer(ITIMER_REAL, &itv, NULL) == -1) ||
136 (sigaction(SIGALRM, &action, NULL) == -1))
140 memset((char *)&vec, 0, sizeof(vec));
141 vec.sv_handler = SIG_DFL;
142 vec.sv_mask = vec.sv_onstack = 0;
144 if ((setitimer(ITIMER_REAL, &itv, (struct itimerval *) 0) == -1) ||
145 (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1))
151 #endif /* AFS_LINUX20_ENV */