[Openais] changing gettimeofday to times

Fabien THOMAS fabien.thomas at netasq.com
Wed Nov 15 06:10:07 PST 2006


> On Tue, 2006-11-14 at 19:02 +0100, Fabien THOMAS wrote:
>> times is also marked obsolete under FreeBSD but it is
>> normal as Darwin came from big part of FreeBSD code.
>>
>> timer_gettime do not exist under BSD and darwin.
>> getitimer/setitimer is supported but i dont see how you will use it
>> to get a timestamp?
>>
>> What i generaly use is  a function that retrieve boot time (that we
>> already have for each platform)
>> and gettimeofday to retrieve current time. uptime is then computed by
>> now - boot.
>> The main problem with this is you need to update the cached value of
>> boottime each
>> time a clock change occur or retrieve it each time you call
>
> How do you know the system clock has changed?  And by how much?  ntp
> will automtically update time during system runtime, which causes
> configuration changes to occur during normal operations.

In our product we have a modified FreeBSD os / kernel so we hook time  
change: this is not a good solution for openais :)
but if the call to retrieve boot time is not too costly or if  
gettimeofday is not called too often it works.

fabien



More information about the Openais mailing list