diff options
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/thread.c b/lib/thread.c index d104c4f598..8c1b3ff06d 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -93,7 +93,8 @@ static void cpu_record_hash_free(void *a) static void vty_out_cpu_thread_history(struct vty *vty, struct cpu_thread_history *a) { - vty_out(vty, "%5d %10lu.%03lu %9u %8lu %9lu %8lu %9lu", a->total_active, + vty_out(vty, "%5"PRIdFAST32" %10lu.%03lu %9"PRIuFAST32 + " %8lu %9lu %8lu %9lu", a->total_active, a->cpu.total / 1000, a->cpu.total % 1000, a->total_calls, a->cpu.total / a->total_calls, a->cpu.max, a->real.total / a->total_calls, a->real.max); @@ -400,7 +401,7 @@ static void cancelreq_del(void *cr) } /* initializer, only ever called once */ -static void initializer() +static void initializer(void) { pthread_key_create(&thread_current, NULL); } @@ -655,20 +656,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 +1573,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)); } /* |
