summaryrefslogtreecommitdiffstats
path: root/lib/libkse
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2000-01-18 11:35:25 +0000
committerdeischen <deischen@FreeBSD.org>2000-01-18 11:35:25 +0000
commit17c111ba77900f6b8d3ba6215144d97c0f59379a (patch)
treee22c36dbe6465d26199f35c776b74df7a5f34cbd /lib/libkse
parentbd6460d3dd910f3e038f201daa206c58c3cfca4d (diff)
downloadFreeBSD-src-17c111ba77900f6b8d3ba6215144d97c0f59379a.zip
FreeBSD-src-17c111ba77900f6b8d3ba6215144d97c0f59379a.tar.gz
Properly initialize the last active time of the initial thread. This fixes
the case that a CPU hungry main thread is prevented from being preempted due to a negative calculation of its time slice. Reported by: Alexander Litvin <archer@lucky.net>
Diffstat (limited to 'lib/libkse')
-rw-r--r--lib/libkse/thread/thr_init.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c
index 051483f..b6429bb 100644
--- a/lib/libkse/thread/thr_init.c
+++ b/lib/libkse/thread/thr_init.c
@@ -90,6 +90,7 @@ _thread_init(void)
int i;
size_t len;
int mib[2];
+ struct timeval tv;
struct clockinfo clockinfo;
struct sigaction act;
@@ -223,6 +224,11 @@ _thread_init(void)
TAILQ_INIT(&(_thread_initial->mutexq));
_thread_initial->priority_mutex_count = 0;
+ /* Initialize last active time to now: */
+ gettimeofday(&tv, NULL);
+ _thread_initial->last_active.tv_sec = tv.tv_sec;
+ _thread_initial->last_active.tv_usec = tv.tv_usec;
+
/* Initialise the rest of the fields: */
_thread_initial->poll_data.nfds = 0;
_thread_initial->poll_data.fds = NULL;
OpenPOWER on IntegriCloud