TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mike Bilow
from: David Muir
date: 1996-02-18 21:32:54
subject: Re: async timer thread

-=> Quoting Mike Bilow to David Muir <=-

 MB> While this may not awaken precisely every second, the aggregate of all
 MB> intervals will still only last nsecs overall, even if the machine is
 MB> busy.  It might also be reasonable to set the thread which runs this
 MB> code to time critical priority, in which case you likely will be
 MB> awakened every second. 

    got it...


 MB> If you are not using C, I doubt I can help you.  Peter is right that,

    I can "translate" most "C" code to Pascal. The API
calls are by necessity 
either identical or very similar to "C", so anything involving the API is 
easily understood. (the only examples of API usage I have are in
"C" and) I 
can usually translate it well enough to get what I need.

 MB> if you need to be awakened each second, then you need to initiate a
 MB> timer with DosStartTimer(), and you need to have created an event
 MB> semaphore using the DosCreateEventSem() or DosOpenEventSem().  The
 MB> thread being awakened must explicitly reset the event semaphore each
 MB> iteration using DosResetEventSem() after being awakened, and must call
 MB> DosWaitEventSem() when it is ready to sleep again.  Finally, you need
 MB> to call DosStopTimer() to release the timer and DosCloseEventSem() to
 MB> release the semaphore.  All of these are 32-bit functions, and you
 MB> need to be consistent.

    No problem... "except" that I am apparently unable to establish a 
semaphore acceptable to DosStartTimer. Could you supply a working example of 
the use of DosStartTimer (doesn't have to do anything really except accept the 
semaphore being passed to it). Using DosCreateEventSem, I receive an error 323 
(invalid semaphore handle).

 MB> I disagree with Peter that this approach would help you.  All you
 MB> would have to do is call DosSleep(1) to achieve the same result, since
 MB> you can never sleep for less that a system timer tick anyway, and this
 MB> is the value you would get back from
 MB> DosQuerySysInfo(QSV_MS_COUNT,...).  I'm not too sure what Peter was
 MB> thinking on that. 

    Actually i am "currently" using that but dividing the
"ms" by 1000 to get 
a seconds change as opposed to a milliseconds change..

    I guess the whole point is that I'm going to way too much trouble unless 
my timing meeds to be absolutely precise (which it doesn't but I had hoped for 
optimum accuracy).
    But now I'm just ticked at my inability to use DosStartTimer moreso than 
actually requiring the ultimate in efficiency. A small sample which correctly 
accepts the semaphore would be appreciated.

Dave...

~~~ TGWave v1.12+
--- GEcho 1.11+
* Origin: fks Online! * Ontario, Canada * (905)820-7273 * (1:259/423)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 259/423 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.