[PATCH v2] Test for clock_nanosleep with CLOCK_MONOTONIC option.

Utkarsh Rai utkarsh.rai60 at gmail.com
Wed Apr 15 12:29:10 UTC 2020


On Wed, Apr 15, 2020 at 5:35 PM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> On 15/04/2020 14:02, Utkarsh Rai wrote:
>
> > +  status = clock_gettime( CLOCK_MONOTONIC, &end_time );
>> > +  rtems_test_assert( status == 0 );
>> > +
>> > +  rtems_test_assert( (end_time.tv_sec-init_time.tv_sec) == 0 );
>>
>> Is end_time.tv_sec - init_time.tv_sec == 0 under all circumstances?
>>
>
> My idea was to check for a 1ns delay with a reasonable amount of overhead,
> hence I checked for  end_time.tv_sec - init_time.tv_sec == 0.
>
> Exists there a value of init_time for which end_time.tv_sec !=
> init_time.tv_sec and still 1ns elapsed?
>

Sorry, maybe I am confused in my concept, kidly help me out. I want to
produce a 1ns delay, so I make a call to clock_nanosleep with flag value as
0 (to sleep for specified time) and the delay being 1ns. I recorded the
time before the sleep call and after the sleep call. Now, I want to check
if the delay produced was actually 1ns with a reasonable overhead, my
assumption for an unreasonable overhead was that if I specify a delay of
1ns and I get a delay in seconds, it would be an error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200415/c7da23f4/attachment-0001.html>


More information about the devel mailing list