Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / client_osi / osistatl.h
1 /* 
2  * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved
3  *
4  * (C) COPYRIGHT IBM CORPORATION 1987, 1988
5  * LICENSED MATERIALS - PROPERTY OF IBM
6  *
7  */
8
9 /* Copyright (C) 1994 Cazamar Systems, Inc. */
10
11 #ifndef _OSISTATL_H_ENV_
12 #define _OSISTATL_H_ENV_ 1
13
14 #include "osibasel.h"
15 #include <largeint.h>
16 #include "osiqueue.h"
17
18 /* structure representing all information about someone holding a lock
19  * or mutex, or about someone waiting for a lock or a mutex.
20  */
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 */
29 } osi_activeInfo_t;
30
31 /* file descriptor for lock seaches */
32 typedef struct osi_statFD {
33         osi_fd_t fd;
34         osi_queue_t *curp;      /* where we're at scan-wise */
35         int which;              /* scanning rwlock or mutex queue */
36 } osi_statFD_t;
37
38 /* real states */
39 #define OSI_STATL_DELETED       1
40
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 */
46 } osi_qiStat_t;
47
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.
53  */
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 */
58         short states;
59
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 */
65
66         osi_qiStat_t qi;
67 } osi_mutexStat_t;
68
69 /* structure referenced by base lock private data pointer
70  * if this is a statistics-gathering mutex.
71  *
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.
75  */
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 */
80         short states;
81
82         /* statistics */
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 */
91
92         osi_qiStat_t qi;                /* queue info */
93 } osi_rwlockStat_t;
94
95 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
96
97 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *);
98
99 extern void lock_InitializeMutexStat(osi_mutex_t *, char *);
100
101 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
102
103 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
104
105 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
106
107 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
108
109 extern void osi_StatInit(void);
110
111 extern void osi_SetStatLog(struct osi_log *logp);
112
113 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
114
115 #endif /*_OSISTATL_H_ENV_ */