3279d0eec7df2bf380496a2fd3ea9e2be3b08483
[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 _OSISTATL_H_ENV_
13 #define _OSISTATL_H_ENV_ 1
14
15 #include "osibasel.h"
16 #include <largeint.h>
17 #include "osiqueue.h"
18
19 /* structure representing all information about someone holding a lock
20  * or mutex, or about someone waiting for a lock or a mutex.
21  */
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 */
30 } osi_activeInfo_t;
31
32 /* file descriptor for lock seaches */
33 typedef struct osi_statFD {
34         osi_fd_t fd;
35         osi_queue_t *curp;      /* where we're at scan-wise */
36         int which;              /* scanning rwlock or mutex queue */
37 } osi_statFD_t;
38
39 /* real states */
40 #define OSI_STATL_DELETED       1
41
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 */
47 } osi_qiStat_t;
48
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.
54  */
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 */
59         short states;
60
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 */
66
67         osi_qiStat_t qi;
68 } osi_mutexStat_t;
69
70 /* structure referenced by base lock private data pointer
71  * if this is a statistics-gathering mutex.
72  *
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.
76  */
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 */
81         short states;
82
83         /* statistics */
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 */
92
93         osi_qiStat_t qi;                /* queue info */
94 } osi_rwlockStat_t;
95
96 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
97
98 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *);
99
100 extern void lock_InitializeMutexStat(osi_mutex_t *, char *);
101
102 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
103
104 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
105
106 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
107
108 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
109
110 extern void osi_StatInit(void);
111
112 extern void osi_SetStatLog(struct osi_log *logp);
113
114 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
115
116 #endif /*_OSISTATL_H_ENV_ */