mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-23 04:11:17 +00:00
Double slack time for busy-wait
This commit is contained in:
parent
1da55066d4
commit
fb80091ac3
2 changed files with 17 additions and 8 deletions
|
@ -376,13 +376,22 @@ void I_SleepDuration(precise_t duration)
|
|||
{
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
UINT64 precision = I_GetPrecisePrecision();
|
||||
struct timespec ts = {
|
||||
.tv_sec = duration / precision,
|
||||
.tv_nsec = duration * 1000000000 / precision % 1000000000,
|
||||
};
|
||||
int status;
|
||||
do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts);
|
||||
while (status == EINTR);
|
||||
precise_t dest = I_GetPreciseTime() + duration;
|
||||
precise_t slack = (precision / 5000); // 0.2 ms slack
|
||||
if (duration > slack)
|
||||
{
|
||||
duration -= slack;
|
||||
struct timespec ts = {
|
||||
.tv_sec = duration / precision,
|
||||
.tv_nsec = duration * 1000000000 / precision % 1000000000,
|
||||
};
|
||||
int status;
|
||||
do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts);
|
||||
while (status == EINTR);
|
||||
}
|
||||
|
||||
// busy-wait the rest
|
||||
while (((INT64)dest - (INT64)I_GetPreciseTime()) > 0);
|
||||
#else
|
||||
UINT64 precision = I_GetPrecisePrecision();
|
||||
INT32 sleepvalue = cv_sleep.value;
|
||||
|
|
|
@ -2310,7 +2310,7 @@ void I_SleepDuration(precise_t duration)
|
|||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__)
|
||||
UINT64 precision = I_GetPrecisePrecision();
|
||||
precise_t dest = I_GetPreciseTime() + duration;
|
||||
precise_t slack = (precision / 10000); // 0.1 ms slack
|
||||
precise_t slack = (precision / 5000); // 0.2 ms slack
|
||||
if (duration > slack)
|
||||
{
|
||||
duration -= slack;
|
||||
|
|
Loading…
Reference in a new issue