[PATCH v2] tests: posix: use cpu clock for sleep

DJ Delorie dj@redhat.com
Thu Feb 12 17:29:24 GMT 2026


Yury Khrustalev <yury.khrustalev@arm.com> writes:
>> If all we need to do is ensure that ctime changes, could we instead call
>> time(), then call sleep(1) until time() changes?
>
> Unfortunately, this doesn't work. Emulated systems that prioritise
> performance in terms of user's time lapsed have effect of sleep()
> or any variant of it returning immediately (with observable effect
> that the result of time() has changed correctly).

In that case, it would busy loop calling usleep() until time() changes,
no different than what you had.  But on non-embedded platforms, usleep()
would not be a busy loop.

>> Busy-waiting may affect how long it takes to run other tests, if "make
>> -j" is used.
>
> I'm sure the effect would be negligible,

I agree, but that doesn't mean we can't try to do better ;-)

(and if you have thousands of tests that each think "it's only a
second"... it's many minutes)



More information about the Libc-alpha mailing list