diff options
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/thread.c b/lib/thread.c index 267dcd1cfc..867ca2dc60 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -68,7 +68,7 @@ static unsigned int cpu_record_hash_key(struct cpu_thread_history *a) return jhash(&a->func, size, 0); } -static int cpu_record_hash_cmp(const struct cpu_thread_history *a, +static bool cpu_record_hash_cmp(const struct cpu_thread_history *a, const struct cpu_thread_history *b) { return a->func == b->func; @@ -434,7 +434,7 @@ struct thread_master *thread_master_create(const char *name) rv->cpu_record = hash_create_size( 8, (unsigned int (*)(void *))cpu_record_hash_key, - (int (*)(const void *, const void *))cpu_record_hash_cmp, + (bool (*)(const void *, const void *))cpu_record_hash_cmp, "Thread Hash"); @@ -655,20 +655,26 @@ void thread_master_free(struct thread_master *m) XFREE(MTYPE_THREAD_MASTER, m); } -/* Return remain time in second. */ -unsigned long thread_timer_remain_second(struct thread *thread) +/* Return remain time in miliseconds. */ +unsigned long thread_timer_remain_msec(struct thread *thread) { int64_t remain; pthread_mutex_lock(&thread->mtx); { - remain = monotime_until(&thread->u.sands, NULL) / 1000000LL; + remain = monotime_until(&thread->u.sands, NULL) / 1000LL; } pthread_mutex_unlock(&thread->mtx); return remain < 0 ? 0 : remain; } +/* Return remain time in seconds. */ +unsigned long thread_timer_remain_second(struct thread *thread) +{ + return thread_timer_remain_msec(thread) / 1000LL; +} + #define debugargdef const char *funcname, const char *schedfrom, int fromln #define debugargpass funcname, schedfrom, fromln @@ -1566,8 +1572,13 @@ void thread_set_yield_time(struct thread *thread, unsigned long yield_time) void thread_getrusage(RUSAGE_T *r) { +#if defined RUSAGE_THREAD +#define FRR_RUSAGE RUSAGE_THREAD +#else +#define FRR_RUSAGE RUSAGE_SELF +#endif monotime(&r->real); - getrusage(RUSAGE_SELF, &(r->cpu)); + getrusage(FRR_RUSAGE, &(r->cpu)); } /* |
