From 17c111ba77900f6b8d3ba6215144d97c0f59379a Mon Sep 17 00:00:00 2001 From: deischen Date: Tue, 18 Jan 2000 11:35:25 +0000 Subject: 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 --- lib/libkse/thread/thr_init.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/libkse/thread/thr_init.c') 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; -- cgit v1.1