[PATCH] posix: Fix relative CLOCK_REALTIME sleep

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Aug 1 08:52:51 UTC 2022


On 01/08/2022 10:48, Chris Johns wrote:
> On 1/8/2022 6:20 pm, Sebastian Huber wrote:
>> On 01/08/2022 10:16, Chris Johns wrote:
>>> On 1/8/2022 5:22 pm, Sebastian Huber wrote:
>>>> A relative CLOCK_REALTIME time out shall not be affected by CLOCK_REALTIME
>>>> changes through clock_settime().  Since our CLOCK_REALTIME is basically just
>>>> CLOCK_MONOTONIC plus an offset, we can simply use the CLOCK_MONOTONIC watchdog
>>>> for relative CLOCK_REALTIME time outs.
>>> Thank for this. I can confirm it works with the modified test code I attached to
>>> the ticket. I am ts-validation-no-clock-0.exe now failing on xilinx_zynq_a9_qemu
>>> but I am not sure?
>> I have to adjust the ts-validation-no-clock-0.exe if we want to fix the issue
>> like this.
>>
>>> There is one issue my test changes have exposed and that is the ticks a thread
>>> sleeps for is 1 more than the requested number.
>> I think this is the expected behaviour. You should sleep at least the requested
>> amount of time.
> I am using 500msec so I would expect the result to be exact? If it was 501msec
> then I would agree.

What do you mean with exact? If you want to wait for 500ms, then you 
will wake up in 500ms plus one clock tick interval (unless you measure 
the start time exactly at the clock tick event which is very unlikely).

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list