Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "P_EventSystem.h"
00032
00033 ClassAllocator<ProxyMutex> mutexAllocator("mutexAllocator");
00034
00035
00036
00037 #ifdef ERROR_CONFIG_TAG_LOCKS
00038 #include "Diags.h"
00039 #endif
00040
00041 #ifdef DEBUG // debug build needs lock_* functions
00042 #undef INK_NO_LOCKS
00043 #endif
00044
00045 void
00046 lock_waiting(const char *file, int line, const char *handler)
00047 {
00048 (void) file;
00049 (void) line;
00050 (void) handler;
00051 #ifdef ERROR_CONFIG_TAG_LOCKS
00052 if (is_diags_on("locks"))
00053 fprintf(stderr, "WARNING: waiting on lock %s:%d for %s\n",
00054 file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
00055 #endif
00056 }
00057
00058 void
00059 lock_holding(const char *file, int line, const char *handler)
00060 {
00061 (void) file;
00062 (void) line;
00063 (void) handler;
00064 #ifdef ERROR_CONFIG_TAG_LOCKS
00065 if (is_diags_on("locks"))
00066 fprintf(stderr, "WARNING: holding lock %s:%d too long for %s\n",
00067 file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
00068 #endif
00069 }
00070
00071 void
00072 lock_taken(const char *file, int line, const char *handler)
00073 {
00074 (void) file;
00075 (void) line;
00076 (void) handler;
00077 #ifdef ERROR_CONFIG_TAG_LOCKS
00078 if (is_diags_on("locks"))
00079 fprintf(stderr, "WARNING: lock %s:%d taken too many times for %s\n",
00080 file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
00081 #endif
00082 }
00083
00084 #ifdef LOCK_CONTENTION_PROFILING
00085 void
00086 ProxyMutex::print_lock_stats(int flag)
00087 {
00088 if (flag) {
00089 if (total_acquires < 10)
00090 return;
00091 printf("Lock Stats (Dying):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n",
00092 successful_nonblocking_acquires,
00093 (nonblocking_acquires > 0 ?
00094 successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0),
00095 unsuccessful_nonblocking_acquires,
00096 (nonblocking_acquires > 0 ?
00097 unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires);
00098 fflush(stdout);
00099 } else {
00100 if (!(total_acquires % 100)) {
00101 printf("Lock Stats (Alive):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n",
00102 successful_nonblocking_acquires,
00103 (nonblocking_acquires > 0 ?
00104 successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0),
00105 unsuccessful_nonblocking_acquires,
00106 (nonblocking_acquires > 0 ?
00107 unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires);
00108 fflush(stdout);
00109 }
00110 }
00111 }
00112 #endif //LOCK_CONTENTION_PROFILING