diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:58:10 -0700 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:58:10 -0700 |
| commit | 50596be0d5ff65c79060bcd858cda33a974a0dc1 (patch) | |
| tree | 4c5532f9924f9afc47af95d3cdfa7141e4e901c9 /lib/thread.c | |
| parent | 5000f21c25dd13d12c3a00b5e702d6f79685a77e (diff) | |
Some small enhancements to thread and workqueue libraries in zebra:
- Allow work queues to specify the yield duration for corresponding background thread
- Support using specified yield duration in thread yielding
- During work queue processing, if using a single list element with a meta-queue
(like done in Zebra), do not exit after each element is processed, instead
update the next-node upon a WQ_REQUEUE so that the WQ processing continues
and is terminated by the yield logic.
- Enhance work queue debug output
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/thread.c b/lib/thread.c index 97448894e5..43bae242c6 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -706,6 +706,7 @@ thread_get (struct thread_master *m, u_char type, thread->func = func; thread->arg = arg; thread->index = -1; + thread->yield = THREAD_YIELD_TIME_SLOT; /* default */ strip_funcname (thread->funcname, funcname); @@ -1198,7 +1199,8 @@ thread_consumed_time (RUSAGE_T *now, RUSAGE_T *start, unsigned long *cputime) return timeval_elapsed (now->real, start->real); } -/* We should aim to yield after THREAD_YIELD_TIME_SLOT milliseconds. +/* We should aim to yield after yield milliseconds, which defaults + to THREAD_YIELD_TIME_SLOT . Note: we are using real (wall clock) time for this calculation. It could be argued that CPU time may make more sense in certain contexts. The things to consider are whether the thread may have @@ -1212,7 +1214,13 @@ thread_should_yield (struct thread *thread) { quagga_get_relative (NULL); return (timeval_elapsed(relative_time, thread->real) > - THREAD_YIELD_TIME_SLOT); + thread->yield); +} + +void +thread_set_yield_time (struct thread *thread, unsigned long yield_time) +{ + thread->yield = yield_time; } void |
