From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8c564a80b820db35 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.229 with SMTP id pz5mr7319217pbc.5.1331055459616; Tue, 06 Mar 2012 09:37:39 -0800 (PST) Path: h9ni46620pbe.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Any leap year issues caused by Ada yesterday? Date: Tue, 6 Mar 2012 18:37:35 +0100 Organization: cbb software GmbH Message-ID: References: <4f4f746a$0$6565$9b4e6d93@newsspool3.arcor-online.net> <20608866.730.1330963171058.JavaMail.geo-discussion-forums@ynbq18> <1t8v4akrmapkl.1xwfi9yxtw2ji$.dlg@40tude.net> <18ghv3yeh1a1k$.1bjwdaps59rt3$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: /bBpnkeEm9kG1v1C1CjDFw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-03-06T18:37:35+01:00 List-Id: On Tue, 06 Mar 2012 16:46:35 +0000, Simon Wright wrote: > "Dmitry A. Kazakov" writes: > >> Under VxWorks you can read the TSC without assembly, there is a library >> function for that (pentiumTscGet64). >> >> type Timestamp is new Unsigned_64; >> procedure pentiumTscGet64 (Clock : out Timestamp); >> pragma Import (C, pentiumTscGet64, "pentiumTscGet64"); >> >> should do the work. > > Not sure if there was an equivalent for PPC. AFAIK, PPC has a high resolution real time counter, which is better designed than Intel's TSC. >> The actual problem is to get the multiplier, the BIOS time, and keeping the >> TSC synchronized with the system clock. Funnily Wind River did all that for >> Pentium IV. But then they were too lazy to support it on more recent x86 >> processors. The most troublesome thing about VxWorks is that Wind River >> adds and removes its parts at will. There is no such thing as backward >> compatibility whatsoever. > > The board manufacturer defined the multiplier for us, so no problems. But there is still a problem of synchronizing it with the system time if that uses a different source, e.g. counted timer interrupts etc. >> As for multicore/sleep mode issues, AFAIK Intel fixed that, i.e. the TSC >> frequency is never changed. I don't know anything about MacOS, but probably >> they deploy the same lousy schema of getting time from the PIT timer or >> something like that, so the problems. > > I think I may have misunderstood the evidence here. Trying it again, the > TSC runs at pretty close to the nominal 2.4 GHz, but it was unreasonable > of me to try to *measure* it by looping for a second and seeing how much > the TSC changed, and then be surprised at errors of the order of a few > milliseconds. Right, the multiplier is not a whole number. Then since the accuracy of system clock is catastrophic under VxWorks, you would not know how long a time interval actually was. The last time I tried something like that under VxWorks, it didn't work. For x86 the multiplier must be taken from the BIOS. It is somehow determined by the frequencies of the front bus and the processor. > But, as you say, you have to calibrate the TSC somehow. If the sources of the TSC and of the system clock are different, then there is a systematic error. I suppose this is the major reason why it did not work under VxWorks. The system time must be derived from the same quartz. Otherwise you have to compensate the deviation, which could well be as big as 5 microseconds per second. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de