Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-03

high performance counter for dos/tp7

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Harald Houppermans

Hello,

I thought I give this newsgroup a try since you guys seem to know so much about all this stuff :D.

Windows has a high performance counter api.

With this api one can read the tick frequency and the tick count.

Dividing the tick count by the tick frequency gives the time that has past or a timestamp.

Substracting two timestamps from each other with care gives one the time that has past pretty accurately.

I need the same functionality in dos.

The high performance counter of windows can be used for millisecond accuracy and even microsecond accuracy.

I have some code available which is for the pit chip (programmable interval timer). For my purposes it would probably be enough to have millisecond accuracy... ( that would interrupt my program thousand times ) if I want microsecond accuracy the pit chip would be set with a frequency of 1 million which would interrupt my program a million times.

So a computer calling an interrupt routine a million times (for microsecond accuracy) that does not seem like a good idea performance wise.

Also calculating the control word (?) can be inaccurate (?):  control_word
:= $1234DD div frequency; ( ??? what about the remainder ??? )

So I don't really need any interrupts... I only need to be able to read some sort of thing that gives me a tick count and possible a tick frequency.

What are my alternatives for dos/turbo pascal 7 ?

( What about 32 bit free pascal :D ? )

Thanks for any help you can give,

Skybuck.

Marco van de Voort
to Harald Houppermans
Show quoted text 10 lines
So a computer calling an interrupt routine a million times (for microsecond accuracy) that does not seem like a good idea performance wise. Also calculating the control word (?) can be inaccurate (?): control_word := $1234DD div frequency; ( ??? what about the remainder ??? ) So I don't really need any interrupts... I only need to be able to read some sort of thing that gives me a tick count and possible a tick frequency. What are my alternatives for dos/turbo pascal 7 ?

Off topic.

( What about 32 bit free pascal :D ? )

Search for Thomas Schatzl's (originally zen-)timer and CPU units. Probably a link is on the contributed units page.

Thomas Schatzl
to Marco van de Voort

Hello,

> So a computer calling an interrupt routine a million times (for

microsecond

> accuracy) that does not seem like a good idea performance wise. > > Also calculating the control word (?) can be inaccurate (?):

control_word

> := $1234DD div frequency; ( ??? what about the remainder ??? ) > > So I don't really need any interrupts... I only need to be able to read

some

Show quoted text 9 lines
> sort of thing that gives me a tick count and possible a tick frequency. > > What are my alternatives for dos/turbo pascal 7 ? Off topic. > ( What about 32 bit free pascal :D ? ) Search for Thomas Schatzl's (originally zen-)timer and CPU units. Probably

a

link is on the contributed units page.

For FPC/Delphi on a few platforms there is my CPU unit, always available via my homepage at http://members.yline.com/~tom_at_work/index.html .

On the same site there's reasonable good documentation available for it; although it dates back to '2001, it's still up to date since nothing else except that it can detect a few more hardware capabilities. All these changes can be found in the accompanying docupd.txt text file...

Basically it offers an OOP timing interface with microsecond accuracy (well, depending on your machine due to some calculation overhead and the usual OS considerations) for most supported x86 FPC platforms I think. Since it is based on the processor's TSC, which counts clock cycles, it is quite useable imo. For the purists it offers direct access to the TSC value as well.

For BP/TP the situation is as follows (as far as I remember it now and can trace it back from my sources)...

<history, skip if not interested; hopefully not too off-topic either> Once upon a time =) there had been some C library called ZenTimer (by M. Abrash iirc, if you ever heard that name), which used the DOS BIOS timer tick counter you mention, and by accident I came across a BP conversion (iirc done by some demo coder whose name I don't know anymore and I can't finde the original sources anymore either).

Since at that time FPC was still in its infancy *g* I ported it for the go32v1 target (a predecessor to the current go32v2) with the same name, added a few things (most notably more accurate TSC support for Pentiums) until it came to version 1.15 (this had been 8.11.'98...) - at that time I decided to give it a little more flexible OO interface, the first incarnation of the CPU unit was born (still FPC only, but with time additional OS/2 + Linux support as I can see from history logs)....

Some time later (actually nearly exactly 4 years ago), at the time the cpu vendors (AMD, Cyrix, Intel, ...) started to go in different directions concerning CPU features, detection etc. so there had been a new instance of my CPU unit with a different API + core that requires much less adaptions for new processors / processor generations. This version still serves its purpose and should work fine with current FPC releases.

Basically meaning that...
</history>

... there has never been an "official" CPU or Zentimer unit for TP/BP from me (except probably very early non-public versions of the ZenTimer unit which I don't have anymore)...

... but afair S. Goehler backported a some version of my CPU unit to TP/BP for his Grafx-unit, can't remember which version (so use your favourite search engine on these keywords :-)

Regards,
Thomas

Harald Houppermans
to Thomas Schatzl

Well I just finished implementing my own high performance unit for timing and timeouts etc... using bios tick count and pit tick count...

thx to some large document ;)

So I thought I'd now give your stuff a look/try :)

But ehm... it seems your website is locked... unable to view/download code etc :)

I thought I'd let you know just in case you forgot to unlock it =D

Thomas Schatzl
to Harald Houppermans

Hello,

Show quoted text 5 lines
But ehm... it seems your website is locked... unable to view/download code etc :) I thought I'd let you know just in case you forgot to unlock it =D

No, this is a public website and I checked the URL I gave you, it works fine from my place. Same goes for the links to the sources, none of them is broken.

Regards,
Thomas

Sigurd Stordal
to Thomas Schatzl
Thomas Schatzl wrote 10 lines
Hello, > But ehm... it seems your website is locked... unable to view/download > code etc :) > > I thought I'd let you know just in case you forgot to unlock it =D No, this is a public website and I checked the URL I gave you, it works fine from my place. Same goes for the links to the sources, none of them is broken.

Same here. No problem viewing, downloading from it.

Sigurd Stordal master in Petrology/mineralogy President of GOGS Opuscreator VO in DNM95
Harald Houppermans
to Thomas Schatzl: No, this is a public website and I checked the URL I gave you, it works fine from my…

----- Original Message -----

Earlier message 33 lines
From: "Thomas Schatzl" To: Sent: Monday, March 22, 2004 12:47 PM Subject: Re: [fpc-pascal]high performance counter for dos/tp7 > Hello, > > > > > But ehm... it seems your website is locked... unable to view/download code > > etc :) > > > > I thought I'd let you know just in case you forgot to unlock it =D > > No, this is a public website and I checked the URL I gave you, it works fine > from my place. Same goes for the links to the sources, none of them is > broken. Indeed, I installed a new version of zone alarm pro and set mobile code control to on. That apparently blocked me from downloading. > > Regards, > Thomas > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal