回复： Is there any method to obtain real-world date and time in Genode?
norman.feske at ...1...
Tue Oct 28 15:23:45 CET 2014
let me add that there is a middle ground between using the RTC driver
and the time-stamp counter (TSC), namely the
'Timer::Session::elapsed_ms' function. This function returns the number
of milliseconds since timer session was created. By combining it with
the RTC driver, the expensive call to the RTC driver could be done at
high intervals only. In between, the less expensive 'elapsed_ms'
function could be used to obtain time durations at a finer granularity.
Still, 'elapsed_ms' does not come for free because it involves an RPC to
the timer service.
Ideally, a get-time function would be a mix of the different facilities.
The RTC to obtain the coarse time of the day and date, the TSC for high
accuracy in the order of microseconds and the 'elapsed_ms' function for
accuracy in the order of milliseconds.
It is true that the TSC frequency may depend on the clock speed, speed
stepping, power savings etc. For this reason, the TSC values cannot be
used as is but they must be calibrated. E.g., the timer service can be
used to determine the ratio of TSC values per second. To account for TSC
frequency changes during runtime, the ratio could be updated at certain
As of now, the libc does not provide a convenient function that combines
the different facilities for you. But the instruments outlined above
should principally enable you to construct a highly accurate get-time
function with very little overhead in the TSC-based common case when
neither 'Timer::Session::elapsed_ms' nor the RTC is called.
Dr.-Ing. Norman Feske
http://www.genode-labs.com · http://genode.org
Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
More information about the users