mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
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:
parent
b37c9b907b
commit
9ffc4537c8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=70233
|
@ -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, ¤t_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, ¤t_time1);
|
||||
|
||||
/* Calculate the remaining time to sleep: */
|
||||
|
|
|
@ -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, ¤t_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, ¤t_time1);
|
||||
|
||||
/* Calculate the remaining time to sleep: */
|
||||
|
|
|
@ -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, ¤t_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, ¤t_time1);
|
||||
|
||||
/* Calculate the remaining time to sleep: */
|
||||
|
|
Loading…
Reference in a new issue