OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/client_osi/osistatl.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /* Copyright (C) 1994 Cazamar Systems, Inc. */
00011 
00012 #ifndef OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H
00013 #define OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H 1
00014 
00015 #include "osibasel.h"
00016 #if !defined(_MSC_VER) || (_MSC_VER < 1300)
00017 #include "largeint.h"
00018 #endif
00019 #include "osiqueue.h"
00020 
00021 /* structure representing all information about someone holding a lock
00022  * or mutex, or about someone waiting for a lock or a mutex.
00023  */
00024 #define OSI_ACTIVEFLAGS_WAITER  1       /* waiting (not owner) */
00025 #define OSI_ACTIVEFLAGS_READER  2       /* for rwlocks, a reader */
00026 #define OSI_ACTIVEFLAGS_WRITER  4       /* for rwlocks, a writer */
00027 typedef struct osi_activeInfo {
00028         osi_queue_t q;          /* queue of all dudes interested in this lock/mutex */
00029         LARGE_INTEGER startTime;        /* time we started doing whatever */
00030         unsigned long tid;      /* thread id */
00031         char flags;             /* flags of interest */
00032 } osi_activeInfo_t;
00033 
00034 /* file descriptor for lock seaches */
00035 typedef struct osi_statFD {
00036         osi_fd_t fd;
00037         osi_queue_t *curp;      /* where we're at scan-wise */
00038         int which;              /* scanning rwlock or mutex queue */
00039 } osi_statFD_t;
00040 
00041 /* real states */
00042 #define OSI_STATL_DELETED       1
00043 
00044 /* common info needed by lock state queueing package */
00045 typedef struct osi_qiStat {
00046         osi_activeInfo_t *activeListp;  /* list of active elements */
00047         char *namep;                    /* for user friendliness */
00048         void *backp;                    /* back ptr to real lock/mutex */
00049 } osi_qiStat_t;
00050 
00051 /* structure referenced by base lock private data pointer
00052  * if this is a statistics-gathering mutex.
00053  * WARNING: we count on the fields q through states having the
00054  * same layout on the mutex and rwlock structures to make following
00055  * pointers in the FD code easier.
00056  */
00057 typedef struct osi_mutexStat {
00058         osi_queue_t q;          /* queue of all mutexes */
00059         osi_turnstile_t turn;   /* the real turnstile */
00060         unsigned long refCount; /* so we can iterate cleanly */
00061         short states;
00062         DWORD tid;
00063 
00064         /* track # of lock calls and blocks */
00065         LARGE_INTEGER lockedTime;       /* total time held */
00066         LARGE_INTEGER blockedTime;/* total time someone was blocked here */
00067         long lockedCount;       /* count of # of obtains */
00068         long blockedCount;      /* count of # of blocks */
00069 
00070         osi_qiStat_t qi;
00071 } osi_mutexStat_t;
00072 
00073 /* structure referenced by base lock private data pointer
00074  * if this is a statistics-gathering mutex.
00075  *
00076  * WARNING: we count on the fields q through states having the
00077  * same layout on the mutex and rwlock structures to make following
00078  * pointers in the FD code easier.
00079  */
00080 typedef struct osi_rwlockStat {
00081         osi_queue_t q;                  /* queue of all mutexes */
00082         osi_turnstile_t turn;           /* the real turnstile */
00083         unsigned long refCount;         /* so we can iterate cleanly */
00084         short states;
00085         DWORD tid[OSI_RWLOCK_THREADS];
00086 
00087         /* statistics */
00088         LARGE_INTEGER writeLockedTime;  /* total time held */
00089         LARGE_INTEGER writeBlockedTime; /* total time someone was blocked here */
00090         LARGE_INTEGER readLockedTime;   /* total time held */
00091         LARGE_INTEGER readBlockedTime;  /* total time someone was blocked here */
00092         long writeLockedCount;          /* count of # of obtains */
00093         long writeBlockedCount;         /* count of # of blocks */
00094         long readLockedCount;           /* count of # of obtains */
00095         long readBlockedCount;          /* count of # of blocks */
00096 
00097         osi_qiStat_t qi;                /* queue info */
00098 } osi_rwlockStat_t;
00099 
00100 typedef void (osi_watchProc_t)(void *rockp, long actualMs, void *lockp);
00101 
00102 extern void lock_InitializeRWLockStat(osi_rwlock_t *, char *, unsigned short level);
00103 
00104 extern void lock_InitializeMutexStat(osi_mutex_t *, char *, unsigned short level);
00105 
00106 extern osi_activeInfo_t *osi_QueueActiveInfo(osi_qiStat_t *, int);
00107 
00108 extern osi_activeInfo_t *osi_FindActiveInfo(osi_qiStat_t *);
00109 
00110 extern void osi_RemoveActiveInfo(osi_qiStat_t *, osi_activeInfo_t *);
00111 
00112 extern void osi_FreeActiveInfo(osi_activeInfo_t *);
00113 
00114 extern void osi_StatInit(void);
00115 
00116 extern void osi_SetStatLog(struct osi_log *logp);
00117 
00118 extern void osi_SetWatchProc(long ms, osi_watchProc_t *procp, void *rockp);
00119 
00120 #endif /* OPENAFS_WINNT_CLIENT_OSI_OSISTATL_H */
 All Data Structures Files Functions Variables