vos: print correct command name in diagnostics for changeloc
[openafs.git] / src / WINNT / client_osi / osistatl.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
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
8  */
9
10 /* Copyright (C) 1994 Cazamar Systems, Inc. */
11
12 #ifndef OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H
13 #define OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H 1
14
15 #include "osibasel.h"
16 #if !defined(_MSC_VER) || (_MSC_VER < 1300)
17 #include "largeint.h"
18 #endif
19 #include "osiqueue.h"
20
21 /* structure representing all information about someone holding a lock
22  * or mutex, or about someone waiting for a lock or a mutex.
23  */
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 */
32 } osi_activeInfo_t;
33
34 /* file descriptor for lock seaches */
35 typedef struct osi_statFD {
36         osi_fd_t fd;
37         osi_queue_t *curp;      /* where we're at scan-wise */
38         int which;              /* scanning rwlock or mutex queue */
39 } osi_statFD_t;
40
41 /* real states */
42 #define OSI_STATL_DELETED       1
43
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 */
49 } osi_qiStat_t;
50
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.
56  */
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 */
61         short states;
62         DWORD tid;
63
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 */
69
70         osi_qiStat_t qi;
71 } osi_mutexStat_t;
72
73 /* structure referenced by base lock private data pointer
74  * if this is a statistics-gathering mutex.
75  *
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.
79  */
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 */
84         short states;
85         DWORD tid;
86
87         /* statistics */
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 */
96
97         osi_qiStat_t qi;                /* queue info */
98 } osi_rwlockStat_t;
99
100 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
101
102 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *, unsigned short level);
103
104 extern void lock_InitializeMutexStat(osi_mutex_t *, char *, unsigned short level);
105
106 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
107
108 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
109
110 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
111
112 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
113
114 extern void osi_StatInit(void);
115
116 extern void osi_SetStatLog(struct osi_log *logp);
117
118 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
119
120 #endif /* OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H */