delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/06/23:37:45

Date: Wed, 7 May 1997 11:19:12 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Roger Noss <noss AT pupk DOT unibe DOT ch>
cc: djgpp AT delorie DOT com
Subject: Re: reliable timer choices
In-Reply-To: <1.5.4.32.19970506133949.002e355c@ubeclu.unibe.ch>
Message-ID: <Pine.SGI.3.93.970507111453.2001A-100000@gibson.eee.upd.edu.ph>
MIME-Version: 1.0

On Tue, 6 May 1997, Roger Noss wrote:

> In the short time I have been reading in this newsgroup, I have seen many
> posts about timers.  It seems to me that a reliable high-resolution timer is
> as important for programmers as a reliable power supply is for hardware
> projects.  Indeed, that's one big reason there is still so much interest in
> DOS, because the timing is reliable.  Nevertheless, reliable timers must
> also exist for Win95/NT environments, because that's the way most computers
> are sold today, so software must be written to run under those multitasking OSs.
[...]

> I remember programming an SGI Iris Indigo in which I could just enable a
> 1-ms-resolution timer, but I had to run as superuser.  I would be happy for
> a similar solution in Win95/NT.  There must be a way.

The problem with timers in _any_ multitasking environment is that the
timer code can be preempted by the kernel, i.e. you can't trust the timer
at all. I'm willing to bet that Indigo's timer would lose some resolution
when the system is paging heavily. Most UNIX systems have either a 1-ms or
10-ms resolution timer, but you shouldn't rely on them too heavily. The
only UNIX'es I'm familiar with that _do_ have reliable timers are Solaris
2.x (which is rated as realtime) and RTLinux, which has hard realtime
capability. Plus Chorus and QNX, but I've not used those.

It's a fundamental characteristic of virtual memory OS's that timers can't
really be trusted. With DJGPP, you could reprogram the timer interrupt,
and lock the ISR in memory so it doesn't get paged out, but that solution
won't be portable. Maybe you can use the realtime clock, although the
resolution is kind of low (32.768 kHz clock). This has the advantage of
working under both DOS and Linux!

-----------------------------------------------------------------------
Orlando Alcantara Andico
WWW:   http://www2.mozcom.com/~orly/           Email:   orly AT mozcom DOT com
ICBM:  14 deg. 30' N, 120 deg. 59' E           POTS:    (+632) 932-2385

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019