1 /* Copyright (C) 1995 Transarc Corporation - All rights reserved. */
3 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
4 * LICENSED MATERIALS - PROPERTY OF IBM
7 #include "../afs/param.h" /* Should be always first */
8 #include "../afs/sysincludes.h" /* Standard vendor system headers */
9 #include "../afs/afsincludes.h" /* Afs-based standard headers */
10 #include "../afs/afs_stats.h" /* afs statistics */
17 /* call procedure aproc with arock as an argument, in ams milliseconds */
18 static int afs_osi_CallProc(aproc, arock, ams)
19 register void (*aproc)();
25 AFS_STATCNT(osi_CallProc);
27 /* hz is in cycles/second, and timeout's 3rd parm is in cycles */
28 code = timeout(aproc, arock, (ams * afs_hz)/1000 + 1);
33 /* cancel a timeout, whether or not it has already occurred */
34 static int afs_osi_CancelProc(aproc, arock)
35 register void (*aproc)();
39 AFS_STATCNT(osi_CancelProc);
42 code = untimeout(aproc, arock);
47 static void AfsWaitHack()
49 AFS_STATCNT(WaitHack);
53 void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
55 AFS_STATCNT(osi_InitWaitHandle);
56 achandle->proc = (caddr_t) 0;
60 void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
64 AFS_STATCNT(osi_CancelWait);
65 proc = achandle->proc;
66 if (proc == 0) return;
67 achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */
68 afs_osi_Wakeup(&waitV);
72 * Waits for data on ahandle, or ams ms later. ahandle may be null.
73 * Returns 0 if timeout and EINTR if signalled.
75 int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
78 afs_int32 endTime, tid;
80 AFS_STATCNT(osi_Wait);
81 endTime = osi_Time() + (ams/1000);
83 ahandle->proc = (caddr_t) u.u_procp;
87 /* do not do anything for solaris, digital, AIX, and SGI MP */
88 afs_osi_CallProc(AfsWaitHack, (char *) u.u_procp, ams);
89 afs_osi_Sleep(&waitV); /* for HP 10.0 */
91 /* do not do anything for solaris, digital, and SGI MP */
92 afs_osi_CancelProc(AfsWaitHack, (char *) u.u_procp);
93 if (code) break; /* if something happened, quit now */
94 /* if we we're cancelled, quit now */
95 if (ahandle && (ahandle->proc == (caddr_t) 0)) {
96 /* we've been signalled */
99 } while (osi_Time() < endTime);