Hi all, Thanks to Stefan, your solution may be good for others, but for my part, it's not decent. Rdtsc varies on different computers of different CPUs, and my project will run on thousands of computers. It's impossible to adjust it to each computer. Moreover, thanks to w_schmidt. My requirement is to record and display system date and time in an audit log app our team made before. When I was using Rtc, it made my genode project very slow. The mouse even cannot move, and the experience of operating was terrible. When I deleted lines related to Rtc, the system returned to normal.
Shuo Wang, University of Chinese Academy of Sciences.
Hi Stefan,
When you say RTC is too slow, what drift did you perceived?
I may add this to the topic. I tried something similiar to measure performance.
First i was a bit irritated that i only get values which are different by one million units, until i looked at the code. https://github.com/genodelabs/genode/blob/master/repos/os/src/drivers/rtc/x8... , line 218 return mktime(day, mon, year, hour, min, sec) * 1000000ULL; -> this only returns something which looks like a timestamp, but has no milliseconds at all.
The second thing is the timing. Using the RDTSC call from https://github.com/genodelabs/genode/blob/master/repos/os/include/x86_64/tra... I tried the following time1 = timestamp(); msleep(1000) time2= timestamp(); which showed that a second of wait is quite equal to the number of time cycles.
Then i tried to emasure the rtc call. time1 = timestamp(); sometestvariable = rtc.get_current_time(); time2= timestamp();
Funnilly this seems to take 0.995 seconds.
So RDTSC seems to be better for perf. measurements.... if and only if you have a fixed processor speed (and a x86 compatible which is not from cyrix, and you always take the same cpu, and...). On modern processors if speed steps are used the rate of ticks is not constant (e.g. due to power saving measures triggered by BIOS). Also if you have multiple processors you will always need to look up the corresponding processor. Some newer intel processors return the TSC always according to the fastest possible processor speed (which is fine).
There are more problems doing measurements with TSC. Because of this, microsoft for example gives the advice to never use the TSC and use methods from the windows api. Also in POSIX RDTSC should not be used, but clock_gettime(). So also on linux you should not use TSC but clock_gettime() / CLOCK_MONOTONIC.
Maybe something to think about in future releases of Genode.
Best regards, Wolfgang
-----Ursprüngliche Nachricht----- From: Stefan Kalkowski Sent: Thursday, October 23, 2014 11:31 AM To: genode-main@lists.sourceforge.net Subject: Re: Is there any method to obtain real-world date and time in Genode?
Hello,
On 10/21/2014 07:33 PM, 王硕 wrote:
Dear Norman and all Genodians,
the Genode OS framework is neither Norman's exclusive project, nor limited to the team working at Genode Labs, but at least meant as an open source community project. Although, Norman and the team at Genode Labs have the greatest influence on the project, and are mostly competent contacts, with this mailing list you address *all* Genode developers and enthusiasts. So _please_: avoid addressing people personally in the first place.
I want to obtain real-world date and time in Genode (base-foc), so would you like to tell me how to achieve it. Rtc is too slow, and Rdtsc can't obtain real time.
When you say RTC is too slow, what drift did you perceived?
Joking apart, your problem is a basic problem in computer science not limited, or special with respect to Genode. I assume with "RTC is too slow" you meant that reading the RTC every time you need a timestamp is to expensive. If you look at existent systems like for instance Linux, the problem is solved in the following way: Calendar time is read exactly once while booting, and stored in a variable. From that on another less expensive system timer is used to add periodically wall-clock time to the initial time-stamp.
To break it down to your problem:
* Initially read the RTC time, as well as the RDTSC * Whenever you want to read the current time, read the RDTSC, and add the difference between the actual and the last RDTSC value to your stored calendar time, and you are done
Regards Stefan
Shuo Wang, University of Chinese Academy of Sciences.
Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho
genode-main mailing list genode-main@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/genode-main