2 ****************************************************************************
3 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, *
7 * provided that the above copyright notice appear in all copies and *
8 * that both that copyright notice and this permission notice appear in *
9 * supporting documentation, and that the name of IBM not be used in *
10 * advertising or publicity pertaining to distribution of the software *
11 * without specific, written prior permission. *
13 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
14 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
15 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
16 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
17 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
18 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 ****************************************************************************
22 /*******************************************************************\
24 * Information Technology Center *
25 * Carnegie-Mellon University *
27 * Bradley White and M. Satyanarayanan *
28 \*******************************************************************/
37 sig_atomic_t PRE_Block
= 0; /* used in lwp.c and process.s */
42 #if defined(AFS_POSIX_SIGNALS)
45 AlarmHandler(int sig
, int code
, struct sigcontext
*scp
)
48 #ifdef AFS_POSIX_SIGNALS
52 if (PRE_Block
== 0 && lwp_cpptr
->level
== 0) {
54 #if defined(AFS_POSIX_SIGNALS)
56 sigaddset(&mask
, sig
);
57 sigprocmask(SIG_UNBLOCK
, &mask
, (sigset_t
*)0);
59 sigsetmask(scp
->sc_mask
);
61 LWP_DispatchProcess();
70 PRE_InitPreempt(struct timeval
*slice
)
73 #ifdef AFS_POSIX_SIGNALS
79 if (lwp_cpptr
== 0) return (LWP_EINIT
);
82 itv
.it_interval
.tv_sec
= itv
.it_value
.tv_sec
= DEFAULTSLICE
;
83 itv
.it_interval
.tv_usec
= itv
.it_value
.tv_usec
= 0;
85 itv
.it_interval
= itv
.it_value
= *slice
;
88 #ifdef AFS_POSIX_SIGNALS
89 sa
.sa_handler
= AlarmHandler
;
94 sa
.sa_flags
= SA_SIGINFO
|SA_NODEFER
;
96 sa
.sa_flags
= SA_NODEFER
;
99 if ((sigaction(SIGALRM
, &sa
, (struct sigaction
*)0) == -1) ||
100 (setitimer(ITIMER_REAL
, &itv
, (struct itimerval
*) 0) == -1))
103 vec
.sv_handler
= AlarmHandler
;
104 vec
.sv_mask
= vec
.sv_onstack
= 0;
106 if ((sigvec(SIGALRM
, &vec
, (struct sigvec
*)0) == -1) ||
107 (setitimer(ITIMER_REAL
, &itv
, (struct itimerval
*) 0) == -1))
117 struct itimerval itv
;
118 #ifdef AFS_POSIX_SIGNALS
127 itv
.it_value
.tv_sec
= itv
.it_value
.tv_usec
= 0;
129 #ifdef AFS_POSIX_SIGNALS
130 sa
.sa_handler
= SIG_DFL
;
133 if ((setitimer(ITIMER_REAL
, &itv
, (struct itimerval
*) 0) == -1) ||
134 (sigaction(SIGALRM
, &sa
, (struct sigaction
*)0) == -1))
137 vec
.sv_handler
= SIG_DFL
;;
138 vec
.sv_mask
= vec
.sv_onstack
= 0;
140 if ((setitimer(ITIMER_REAL
, &itv
, (struct itimerval
*) 0) == -1) ||
141 (sigvec(SIGALRM
, &vec
, (struct sigvec
*)0) == -1))
148 #else /* !HAVE_GETITIMER */
151 PRE_InitPreempt(struct timeval
*slice
)
162 #endif /* HAVE_GETITIMER */