diff options
author | Ken Raeburn <raeburn@mit.edu> | 2008-08-27 00:21:53 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2008-08-27 00:21:53 +0000 |
commit | 6f207872f88b0c63e0ec81041f8c54b6b68f73f5 (patch) | |
tree | 076729cd32085f40a48a541c27ca3b65aecc2746 /src/util/support/threads.c | |
parent | 5eae0ec203bfc36b23707e4141e2260ef6d69c63 (diff) | |
download | krb5-6f207872f88b0c63e0ec81041f8c54b6b68f73f5.tar.gz krb5-6f207872f88b0c63e0ec81041f8c54b6b68f73f5.tar.xz krb5-6f207872f88b0c63e0ec81041f8c54b6b68f73f5.zip |
r820@NOME-KING: raeburn | 2008-08-26 18:37:41 -0400
x
r821@NOME-KING: raeburn | 2008-08-26 18:51:10 -0400
Remove disabled statistics gathering support.
r822@NOME-KING: raeburn | 2008-08-26 18:57:20 -0400
Remove source location tracking.
r823@NOME-KING: raeburn | 2008-08-26 19:05:35 -0400
Delete DEBUG_THREADS code.
r824@NOME-KING: raeburn | 2008-08-26 19:18:59 -0400
Remove now-no-op assertion checks.
r825@NOME-KING: raeburn | 2008-08-26 19:29:49 -0400
Simplify some wrappers.
r826@NOME-KING: raeburn | 2008-08-26 19:38:23 -0400
Remove redundant comment.
r827@NOME-KING: raeburn | 2008-08-26 19:49:20 -0400
When pthreads must be checked for at run time, don't include the no-op _nothread_mutex stuff too.
r828@NOME-KING: raeburn | 2008-08-26 19:54:05 -0400
Remove remaining DEBUG_THREADS bits.
r829@NOME-KING: raeburn | 2008-08-26 20:00:22 -0400
fix up initializer
r830@NOME-KING: raeburn | 2008-08-26 20:10:37 -0400
Flatten a couple of structs wrapping single elements.
r831@NOME-KING: raeburn | 2008-08-26 20:14:01 -0400
Remove k5_pthread_mutex_*lock macros.
r832@NOME-KING: raeburn | 2008-08-26 20:19:14 -0400
Update comments a bit for lack of debug support.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20696 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/support/threads.c')
-rw-r--r-- | src/util/support/threads.c | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/src/util/support/threads.c b/src/util/support/threads.c index b30989df1..316be8a1c 100644 --- a/src/util/support/threads.c +++ b/src/util/support/threads.c @@ -412,11 +412,6 @@ int krb5int_call_thread_support_init (void) #include "cache-addrinfo.h" -#ifdef DEBUG_THREADS_STATS -#include <stdio.h> -static FILE *stats_logfile; -#endif - int krb5int_thread_support_init (void) { int err; @@ -425,15 +420,6 @@ int krb5int_thread_support_init (void) printf("krb5int_thread_support_init\n"); #endif -#ifdef DEBUG_THREADS_STATS - /* stats_logfile = stderr; */ - stats_logfile = fopen("/dev/tty", "w+"); - if (stats_logfile == NULL) - stats_logfile = stderr; - else - set_cloexec_file(stats_logfile); -#endif - #ifndef ENABLE_THREADS /* Nothing to do for TLS initialization. */ @@ -498,127 +484,9 @@ void krb5int_thread_support_fini (void) #endif -#ifdef DEBUG_THREADS_STATS - fflush(stats_logfile); - /* XXX Should close if not stderr, in case unloading library but - not exiting. */ -#endif - krb5int_fini_fac(); } -#ifdef DEBUG_THREADS_STATS -void KRB5_CALLCONV -k5_mutex_lock_update_stats(k5_debug_mutex_stats *m, - k5_mutex_stats_tmp startwait) -{ - k5_debug_time_t now; - k5_debug_timediff_t tdiff, tdiff2; - - now = get_current_time(); - (void) krb5int_call_thread_support_init(); - m->count++; - m->time_acquired = now; - tdiff = timediff(now, startwait); - tdiff2 = tdiff * tdiff; - if (m->count == 1 || m->lockwait.valmin > tdiff) - m->lockwait.valmin = tdiff; - if (m->count == 1 || m->lockwait.valmax < tdiff) - m->lockwait.valmax = tdiff; - m->lockwait.valsum += tdiff; - m->lockwait.valsqsum += tdiff2; -} - -void KRB5_CALLCONV -krb5int_mutex_unlock_update_stats(k5_debug_mutex_stats *m) -{ - k5_debug_time_t now = get_current_time(); - k5_debug_timediff_t tdiff, tdiff2; - tdiff = timediff(now, m->time_acquired); - tdiff2 = tdiff * tdiff; - if (m->count == 1 || m->lockheld.valmin > tdiff) - m->lockheld.valmin = tdiff; - if (m->count == 1 || m->lockheld.valmax < tdiff) - m->lockheld.valmax = tdiff; - m->lockheld.valsum += tdiff; - m->lockheld.valsqsum += tdiff2; -} - -#include <math.h> -static inline double -get_stddev(struct k5_timediff_stats sp, int count) -{ - long double mu, mu_squared, rho_squared; - mu = (long double) sp.valsum / count; - mu_squared = mu * mu; - /* SUM((x_i - mu)^2) - = SUM(x_i^2 - 2*mu*x_i + mu^2) - = SUM(x_i^2) - 2*mu*SUM(x_i) + N*mu^2 - - Standard deviation rho^2 = SUM(...) / N. */ - rho_squared = (sp.valsqsum - 2 * mu * sp.valsum + count * mu_squared) / count; - return sqrt(rho_squared); -} - -void KRB5_CALLCONV -krb5int_mutex_report_stats(k5_mutex_t *m) -{ - char *p; - - /* Tweak this to only record data on "interesting" locks. */ - if (m->stats.count < 10) - return; - if (m->stats.lockwait.valsum < 10 * m->stats.count) - return; - - p = strrchr(m->loc_created.filename, '/'); - if (p == NULL) - p = m->loc_created.filename; - else - p++; - fprintf(stats_logfile, "mutex @%p: created at line %d of %s\n", - (void *) m, m->loc_created.lineno, p); - if (m->stats.count == 0) - fprintf(stats_logfile, "\tnever locked\n"); - else { - double sd_wait, sd_hold; - sd_wait = get_stddev(m->stats.lockwait, m->stats.count); - sd_hold = get_stddev(m->stats.lockheld, m->stats.count); - fprintf(stats_logfile, - "\tlocked %d time%s; wait %lu/%f/%lu/%fus, hold %lu/%f/%lu/%fus\n", - m->stats.count, m->stats.count == 1 ? "" : "s", - (unsigned long) m->stats.lockwait.valmin, - (double) m->stats.lockwait.valsum / m->stats.count, - (unsigned long) m->stats.lockwait.valmax, - sd_wait, - (unsigned long) m->stats.lockheld.valmin, - (double) m->stats.lockheld.valsum / m->stats.count, - (unsigned long) m->stats.lockheld.valmax, - sd_hold); - } -} -#else -/* On Windows, everything defined in the export list must be defined. - The UNIX systems where we're using the export list don't seem to - care. */ -#undef krb5int_mutex_lock_update_stats -void KRB5_CALLCONV -krb5int_mutex_lock_update_stats(k5_debug_mutex_stats *m, - k5_mutex_stats_tmp startwait) -{ -} -#undef krb5int_mutex_unlock_update_stats -void KRB5_CALLCONV -krb5int_mutex_unlock_update_stats(k5_debug_mutex_stats *m) -{ -} -#undef krb5int_mutex_report_stats -void KRB5_CALLCONV -krb5int_mutex_report_stats(k5_mutex_t *m) -{ -} -#endif - /* Mutex allocation functions, for use in plugins that may not know what options a given set of libraries was compiled with. */ int KRB5_CALLCONV |