When retrieving the time of day in nanosleep(), store it in the

global time of day.  This costs us nothing, but is a bit of a hack
to work around a process blocking and not having the time updated
by an ITIMER_PROF signal.

PR:		23679
This commit is contained in:
Daniel Eischen 2000-12-20 17:04:12 +00:00
parent b37c9b907b
commit 9ffc4537c8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=70233
3 changed files with 36 additions and 12 deletions

View file

@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */

View file

@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */

View file

@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
/* Get the current time: */
gettimeofday(&tv, NULL);
/*
* As long as we're going to get the time of day, we
* might as well store it in the global time of day:
*/
gettimeofday((struct timeval *) &_sched_tod, NULL);
GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */