summaryrefslogtreecommitdiffstats
path: root/lib/thread.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-03-30 13:44:03 +0300
committerTimo Teräs <timo.teras@iki.fi>2016-03-30 14:29:40 +0300
commit8cb40c91cdfb00ddf04e88d3ecd40403890d90f7 (patch)
tree6d6a3de27525820abb740f1fa8347b6f03986bad /lib/thread.c
parent86c5d2ee68f7b9c00ae4aeb5c8b3c5d82c5ebffc (diff)
downloadquagga-8cb40c91cdfb00ddf04e88d3ecd40403890d90f7.tar.bz2
quagga-8cb40c91cdfb00ddf04e88d3ecd40403890d90f7.tar.xz
cumulus take-3cumulus-take-3
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/thread.c b/lib/thread.c
index 5e40261e..f72e67ea 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -57,8 +57,6 @@ static unsigned short timers_inited;
static struct hash *cpu_record = NULL;
-/* Struct timeval's tv_usec one second value. */
-#define TIMER_SECOND_MICRO 1000000L
/* Adjust so that tv_usec is in the range [0,TIMER_SECOND_MICRO).
And change negative values to 0. */
@@ -691,6 +689,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 */
thread->funcname = funcname;
thread->schedfrom = schedfrom;
@@ -1190,7 +1189,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
@@ -1204,7 +1204,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