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 #include <afsconfig.h>
11 #include "afs/param.h"
14 #include "afs/sysincludes.h" /* Standard vendor system headers */
15 #include "afsincludes.h" /* Afs-based standard headers */
16 #include "afs/afs_stats.h" /* afs statistics */
18 #if !defined(AFS_HPUX110_ENV)
22 /* call procedure aproc with arock as an argument, in ams milliseconds */
24 afs_osi_CallProc(aproc
, arock
, ams
)
31 AFS_STATCNT(osi_CallProc
);
32 #if !defined(AFS_HPUX110_ENV)
35 /* hz is in cycles/second, and timeout's 3rd parm is in cycles */
36 code
= timeout(aproc
, arock
, (ams
* afs_hz
) / 1000 + 1);
37 #if !defined(AFS_HPUX110_ENV)
43 /* cancel a timeout, whether or not it has already occurred */
45 afs_osi_CancelProc(aproc
, arock
)
50 AFS_STATCNT(osi_CancelProc
);
52 #if !defined(AFS_HPUX110_ENV)
55 code
= untimeout(aproc
, arock
);
56 #if !defined(AFS_HPUX110_ENV)
62 #if defined(AFS_HPUX110_ENV)
64 AfsWaitHack(char *event
)
68 AFS_STATCNT(WaitHack
);
69 sleep_lock
= get_sleep_lock(event
);
71 spinunlock(sleep_lock
);
78 AFS_STATCNT(WaitHack
);
84 afs_osi_InitWaitHandle(struct afs_osi_WaitHandle
*achandle
)
86 AFS_STATCNT(osi_InitWaitHandle
);
87 achandle
->proc
= (caddr_t
) 0;
92 afs_osi_CancelWait(struct afs_osi_WaitHandle
*achandle
)
96 AFS_STATCNT(osi_CancelWait
);
97 proc
= achandle
->proc
;
100 achandle
->proc
= (caddr_t
) 0; /* so dude can figure out he was signalled */
101 #if defined(AFS_HPUX110_ENV)
102 afs_osi_Wakeup((char *)achandle
);
104 afs_osi_Wakeup(&waitV
);
110 * Waits for data on ahandle, or ams ms later. ahandle may be null.
111 * Returns 0 if timeout and EINTR if signalled.
114 afs_osi_Wait(afs_int32 ams
, struct afs_osi_WaitHandle
*ahandle
, int aintok
)
117 afs_int32 endTime
, tid
;
118 #if defined(AFS_HPUX110_ENV)
123 AFS_STATCNT(osi_Wait
);
124 endTime
= osi_Time() + (ams
/ 1000);
126 ahandle
->proc
= (caddr_t
) u
.u_procp
;
130 /* do not do anything for solaris, digital, AIX, and SGI MP */
131 #if defined(AFS_HPUX110_ENV)
133 event
= (char *)ahandle
;
137 afs_osi_CallProc(AfsWaitHack
, event
, ams
);
138 afs_osi_Sleep(event
);
139 afs_osi_CancelProc(AfsWaitHack
, event
);
141 afs_osi_CallProc(AfsWaitHack
, (char *)u
.u_procp
, ams
);
142 afs_osi_Sleep(&waitV
); /* for HP 10.0 */
144 /* do not do anything for solaris, digital, and SGI MP */
145 afs_osi_CancelProc(AfsWaitHack
, (char *)u
.u_procp
);
147 break; /* if something happened, quit now */
149 /* if we we're cancelled, quit now */
150 if (ahandle
&& (ahandle
->proc
== (caddr_t
) 0)) {
151 /* we've been signalled */
154 } while (osi_Time() < endTime
);
159 afs_osi_SleepSig(void *event
)
161 afs_osi_Sleep(event
);
165 #if defined(AFS_HPUX110_ENV)
167 afs_osi_TimedSleep(void *event
, afs_int32 ams
, int aintok
)
170 int intr
= EWOULDBLOCK
;
174 afs_osi_CallProc(AfsWaitHack
, event
, ams
);
175 sleep((caddr_t
) event
, PZERO
- 2);
176 if (afs_osi_CancelProc(AfsWaitHack
, event
) < 0)
183 afs_osi_Sleep(void *event
)
188 get_sleep_lock(event
);
190 sleep((caddr_t
) event
, PZERO
- 2);
195 afs_osi_Wakeup(void *event
)
199 sleep_lock
= get_sleep_lock(event
);
200 wakeup((caddr_t
) event
);
201 spinunlock(sleep_lock
);
206 afs_osi_Wakeup(void *event
)
208 wakeup((caddr_t
) event
);