fix epicsThreadSleepQuantum not to fail epicsTimeTest because of unrealistically high clock resolution
This commit is contained in:
@@ -1024,13 +1024,21 @@ LIBCOM_API void epicsStdCall *epicsThreadPrivateGet(epicsThreadPrivateId id)
|
||||
|
||||
LIBCOM_API double epicsStdCall epicsThreadSleepQuantum ()
|
||||
{
|
||||
#ifdef CLOCK_REALTIME
|
||||
struct timespec res;
|
||||
if (clock_getres(CLOCK_REALTIME, &res) == 0)
|
||||
return res.tv_sec + 1e-9 * res.tv_nsec;
|
||||
else
|
||||
double hz;
|
||||
#ifndef CLOCK_MONOTONIC_COARSE
|
||||
#ifdef CLOCK_MONOTONIC
|
||||
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
|
||||
#else
|
||||
#define CLOCK_MONOTONIC_COARSE CLOCK_REALTIME
|
||||
#endif
|
||||
return 1e-3;
|
||||
#endif
|
||||
struct timespec res;
|
||||
if (clock_getres(CLOCK_MONOTONIC_COARSE, &res) == 0)
|
||||
return res.tv_sec + 1e-9 * res.tv_nsec;
|
||||
hz = sysconf ( _SC_CLK_TCK );
|
||||
if(hz<=0)
|
||||
return 0.0;
|
||||
return 1.0 / hz;
|
||||
}
|
||||
|
||||
LIBCOM_API int epicsThreadGetCPUs(void)
|
||||
|
||||
Reference in New Issue
Block a user