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 /* Copyright (C) 1994 Cazamar Systems, Inc. */
12 #ifndef _OSISTATL_H_ENV_
13 #define _OSISTATL_H_ENV_ 1
19 /* structure representing all information about someone holding a lock
20 * or mutex, or about someone waiting for a lock or a mutex.
22 #define OSI_ACTIVEFLAGS_WAITER 1 /* waiting (not owner) */
23 #define OSI_ACTIVEFLAGS_READER 2 /* for rwlocks, a reader */
24 #define OSI_ACTIVEFLAGS_WRITER 4 /* for rwlocks, a writer */
25 typedef struct osi_activeInfo {
26 osi_queue_t q; /* queue of all dudes interested in this lock/mutex */
27 LARGE_INTEGER startTime; /* time we started doing whatever */
28 unsigned long tid; /* thread id */
29 char flags; /* flags of interest */
32 /* file descriptor for lock seaches */
33 typedef struct osi_statFD {
35 osi_queue_t *curp; /* where we're at scan-wise */
36 int which; /* scanning rwlock or mutex queue */
40 #define OSI_STATL_DELETED 1
42 /* common info needed by lock state queueing package */
43 typedef struct osi_qiStat {
44 osi_activeInfo_t *activeListp; /* list of active elements */
45 char *namep; /* for user friendliness */
46 void *backp; /* back ptr to real lock/mutex */
49 /* structure referenced by base lock private data pointer
50 * if this is a statistics-gathering mutex.
51 * WARNING: we count on the fields q through states having the
52 * same layout on the mutex and rwlock structures to make following
53 * pointers in the FD code easier.
55 typedef struct osi_mutexStat {
56 osi_queue_t q; /* queue of all mutexes */
57 osi_turnstile_t turn; /* the real turnstile */
58 short refCount; /* so we can iterate cleanly */
61 /* track # of lock calls and blocks */
62 LARGE_INTEGER lockedTime; /* total time held */
63 LARGE_INTEGER blockedTime;/* total time someone was blocked here */
64 long lockedCount; /* count of # of obtains */
65 long blockedCount; /* count of # of blocks */
70 /* structure referenced by base lock private data pointer
71 * if this is a statistics-gathering mutex.
73 * WARNING: we count on the fields q through states having the
74 * same layout on the mutex and rwlock structures to make following
75 * pointers in the FD code easier.
77 typedef struct osi_rwlockStat {
78 osi_queue_t q; /* queue of all mutexes */
79 osi_turnstile_t turn; /* the real turnstile */
80 short refCount; /* so we can iterate cleanly */
84 LARGE_INTEGER writeLockedTime; /* total time held */
85 LARGE_INTEGER writeBlockedTime; /* total time someone was blocked here */
86 LARGE_INTEGER readLockedTime; /* total time held */
87 LARGE_INTEGER readBlockedTime; /* total time someone was blocked here */
88 long writeLockedCount; /* count of # of obtains */
89 long writeBlockedCount; /* count of # of blocks */
90 long readLockedCount; /* count of # of obtains */
91 long readBlockedCount; /* count of # of blocks */
93 osi_qiStat_t qi; /* queue info */
96 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
98 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *);
100 extern void lock_InitializeMutexStat(osi_mutex_t *, char *);
102 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
104 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
106 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
108 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
110 extern void osi_StatInit(void);
112 extern void osi_SetStatLog(struct osi_log *logp);
114 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
116 #endif /*_OSISTATL_H_ENV_ */