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 OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H
13 #define OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H 1
16 #if !defined(_MSC_VER) || (_MSC_VER < 1300)
21 /* structure representing all information about someone holding a lock
22 * or mutex, or about someone waiting for a lock or a mutex.
24 #define OSI_ACTIVEFLAGS_WAITER 1 /* waiting (not owner) */
25 #define OSI_ACTIVEFLAGS_READER 2 /* for rwlocks, a reader */
26 #define OSI_ACTIVEFLAGS_WRITER 4 /* for rwlocks, a writer */
27 typedef struct osi_activeInfo {
28 osi_queue_t q; /* queue of all dudes interested in this lock/mutex */
29 LARGE_INTEGER startTime; /* time we started doing whatever */
30 unsigned long tid; /* thread id */
31 char flags; /* flags of interest */
34 /* file descriptor for lock seaches */
35 typedef struct osi_statFD {
37 osi_queue_t *curp; /* where we're at scan-wise */
38 int which; /* scanning rwlock or mutex queue */
42 #define OSI_STATL_DELETED 1
44 /* common info needed by lock state queueing package */
45 typedef struct osi_qiStat {
46 osi_activeInfo_t *activeListp; /* list of active elements */
47 char *namep; /* for user friendliness */
48 void *backp; /* back ptr to real lock/mutex */
51 /* structure referenced by base lock private data pointer
52 * if this is a statistics-gathering mutex.
53 * WARNING: we count on the fields q through states having the
54 * same layout on the mutex and rwlock structures to make following
55 * pointers in the FD code easier.
57 typedef struct osi_mutexStat {
58 osi_queue_t q; /* queue of all mutexes */
59 osi_turnstile_t turn; /* the real turnstile */
60 unsigned long refCount; /* so we can iterate cleanly */
64 /* track # of lock calls and blocks */
65 LARGE_INTEGER lockedTime; /* total time held */
66 LARGE_INTEGER blockedTime;/* total time someone was blocked here */
67 long lockedCount; /* count of # of obtains */
68 long blockedCount; /* count of # of blocks */
73 /* structure referenced by base lock private data pointer
74 * if this is a statistics-gathering mutex.
76 * WARNING: we count on the fields q through states having the
77 * same layout on the mutex and rwlock structures to make following
78 * pointers in the FD code easier.
80 typedef struct osi_rwlockStat {
81 osi_queue_t q; /* queue of all mutexes */
82 osi_turnstile_t turn; /* the real turnstile */
83 unsigned long refCount; /* so we can iterate cleanly */
88 LARGE_INTEGER writeLockedTime; /* total time held */
89 LARGE_INTEGER writeBlockedTime; /* total time someone was blocked here */
90 LARGE_INTEGER readLockedTime; /* total time held */
91 LARGE_INTEGER readBlockedTime; /* total time someone was blocked here */
92 long writeLockedCount; /* count of # of obtains */
93 long writeBlockedCount; /* count of # of blocks */
94 long readLockedCount; /* count of # of obtains */
95 long readBlockedCount; /* count of # of blocks */
97 osi_qiStat_t qi; /* queue info */
100 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
102 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *, unsigned short level);
104 extern void lock_InitializeMutexStat(osi_mutex_t *, char *, unsigned short level);
106 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
108 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
110 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
112 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
114 extern void osi_StatInit(void);
116 extern void osi_SetStatLog(struct osi_log *logp);
118 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
120 #endif /* OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H */