| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | async timer thread |
David Muir wrote in a message to All:
DM> I need help with a thread who's sole task is to count
DM> seconds from 60 down to 1. Seems simple enough, use
DM> DosTimerAsync. No matter...
You don't need DosTimerAsync(), which consumes a system timer resource.
You need, instead, to read and store the system time of day and sleep for a
while, waking up every so often to check if the required interval has
passed, then sleeping again for about half the interval remaining:
time_t nsecs, dsecs, fsecs;
nsecs = (time_t)60; /* number of seconds to wait */
fsecs = time(NULL) + nsecs; /* time at finish */
while ((dsecs = fsecs - time(NULL)) > (time_t)0)
DosSleep((long)dsecs << 9); /* (dsecs * 1024 / 2) */
DM> I can't seem to assign a semaphore acceptable to this
DM> API call. The PRCP.INF is useless as it uses DosCreateSem
DM> and I don't have such a beast available to me. The only
DM> semaphore creators I see are event/muxwait/mutex. But not
DM> matter which type I create, the DosTimerAsync call returns
DM> 323 (ERROR_TS_SEMAPHORE - Invalid System Semaphore).
PRCP.INF documents the 16-bit OS/2 API, which uses untyped semaphores named
in the "\SEM" hierarchy, while the 32-bit OS/2 API uses typed
semaphores named in the "\SEM32" hierarchy. You can find the
documentation for the 32-bit calls in the Control Program Reference
(GUIREF20.INF) rather than PRCP.INF.
DM> So.... How do I initialize a semaphore acceptable to
DM> DosTimerAsync? I would appreciate any example (in C or
DM> Pascal) of a proper setup and initializing of DosTimerAsync
DM> or any timer thread which is blocked.
You don't need DosTimerAsync() to sit around and wait for 60 seconds of
absolute time. You are wise to do something more sophisticated than
DosSleep(), which measures process CPU time, if absolute time is important.
DM> Mike? Pete? Jonathon?.. Bill? Sue? Andrea? Hans?
DM> ANYBODY??
:-)
DM> Of course if I'm just looking too hard in the wrong
DM> direction, I'd settle for being pointed in the right
DM> direction.
Aha!
-- Mike
---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)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: 323/107 170/400 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™.