refactor: generic thread

main
Sean McBride 4 years ago
parent aa77d07f75
commit f665c6ab1f

@ -2,25 +2,8 @@
#include <stdint.h> #include <stdint.h>
#include "arch/getcycles.h"
#include "debuglog.h"
extern __thread uint64_t generic_thread_lock_duration; extern __thread uint64_t generic_thread_lock_duration;
extern __thread uint64_t generic_thread_start_timestamp; extern __thread uint64_t generic_thread_start_timestamp;
/** void generic_thread_dump_lock_overhead();
* Reports lock contention
*/
static inline void
generic_thread_dump_lock_overhead()
{
#ifndef NDEBUG
#ifdef LOG_LOCK_OVERHEAD
uint64_t duration = __getcycles() - generic_thread_start_timestamp;
debuglog("Locks consumed %lu / %lu cycles, or %f%%\n", generic_thread_lock_duration, duration,
(double)generic_thread_lock_duration / duration * 100);
#endif
#endif
}
void generic_thread_initialize(); void generic_thread_initialize();

@ -1,6 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include "arch/getcycles.h" #include "arch/getcycles.h"
#include "debuglog.h"
/* Implemented by listener and workers */ /* Implemented by listener and workers */
@ -13,3 +14,18 @@ generic_thread_initialize()
generic_thread_start_timestamp = __getcycles(); generic_thread_start_timestamp = __getcycles();
generic_thread_lock_duration = 0; generic_thread_lock_duration = 0;
} }
/**
* Reports lock contention
*/
void
generic_thread_dump_lock_overhead()
{
#ifndef NDEBUG
#ifdef LOG_LOCK_OVERHEAD
uint64_t duration = __getcycles() - generic_thread_start_timestamp;
debuglog("Locks consumed %lu / %lu cycles, or %f%%\n", generic_thread_lock_duration, duration,
(double)generic_thread_lock_duration / duration * 100);
#endif
#endif
}

Loading…
Cancel
Save