2 * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved
4 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
5 * LICENSED MATERIALS - PROPERTY OF IBM
9 /* Copyright (C) 1994 Cazamar Systems, Inc. */
11 #ifndef _OSISTATL_H_ENV_
12 #define _OSISTATL_H_ENV_ 1
18 /* structure representing all information about someone holding a lock
19 * or mutex, or about someone waiting for a lock or a mutex.
21 #define OSI_ACTIVEFLAGS_WAITER 1 /* waiting (not owner) */
22 #define OSI_ACTIVEFLAGS_READER 2 /* for rwlocks, a reader */
23 #define OSI_ACTIVEFLAGS_WRITER 4 /* for rwlocks, a writer */
24 typedef struct osi_activeInfo {
25 osi_queue_t q; /* queue of all dudes interested in this lock/mutex */
26 LARGE_INTEGER startTime; /* time we started doing whatever */
27 unsigned long tid; /* thread id */
28 char flags; /* flags of interest */
31 /* file descriptor for lock seaches */
32 typedef struct osi_statFD {
34 osi_queue_t *curp; /* where we're at scan-wise */
35 int which; /* scanning rwlock or mutex queue */
39 #define OSI_STATL_DELETED 1
41 /* common info needed by lock state queueing package */
42 typedef struct osi_qiStat {
43 osi_activeInfo_t *activeListp; /* list of active elements */
44 char *namep; /* for user friendliness */
45 void *backp; /* back ptr to real lock/mutex */
48 /* structure referenced by base lock private data pointer
49 * if this is a statistics-gathering mutex.
50 * WARNING: we count on the fields q through states having the
51 * same layout on the mutex and rwlock structures to make following
52 * pointers in the FD code easier.
54 typedef struct osi_mutexStat {
55 osi_queue_t q; /* queue of all mutexes */
56 osi_turnstile_t turn; /* the real turnstile */
57 short refCount; /* so we can iterate cleanly */
60 /* track # of lock calls and blocks */
61 LARGE_INTEGER lockedTime; /* total time held */
62 LARGE_INTEGER blockedTime;/* total time someone was blocked here */
63 long lockedCount; /* count of # of obtains */
64 long blockedCount; /* count of # of blocks */
69 /* structure referenced by base lock private data pointer
70 * if this is a statistics-gathering mutex.
72 * WARNING: we count on the fields q through states having the
73 * same layout on the mutex and rwlock structures to make following
74 * pointers in the FD code easier.
76 typedef struct osi_rwlockStat {
77 osi_queue_t q; /* queue of all mutexes */
78 osi_turnstile_t turn; /* the real turnstile */
79 short refCount; /* so we can iterate cleanly */
83 LARGE_INTEGER writeLockedTime; /* total time held */
84 LARGE_INTEGER writeBlockedTime; /* total time someone was blocked here */
85 LARGE_INTEGER readLockedTime; /* total time held */
86 LARGE_INTEGER readBlockedTime; /* total time someone was blocked here */
87 long writeLockedCount; /* count of # of obtains */
88 long writeBlockedCount; /* count of # of blocks */
89 long readLockedCount; /* count of # of obtains */
90 long readBlockedCount; /* count of # of blocks */
92 osi_qiStat_t qi; /* queue info */
95 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
97 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *);
99 extern void lock_InitializeMutexStat(osi_mutex_t *, char *);
101 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
103 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
105 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
107 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
109 extern void osi_StatInit(void);
111 extern void osi_SetStatLog(struct osi_log *logp);
113 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
115 #endif /*_OSISTATL_H_ENV_ */