home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
turbo_c
/
tick.arc
/
TICK.DOC
< prev
next >
Wrap
Text File
|
1988-03-08
|
3KB
|
63 lines
All the functions in this file make heavy use of TurboC and PCDOS
facilities and are not portable.
WARNING:
DO NOT compile with tiny, small or medium models. Stack overflow
occurs and if the stack checking option of the compiler is used
then the timers are not unloaded and the system crashes - in fact
you have to setup the entire system from scratch.
USAGE:
#include "tick.h"
int install_timer(vod (*func());
Installs the function "func()" to be called EVERY tick.
Removes the function on exit from the program - both if
^C or normal. You MUST NOT use the Turbo C supplied
ctrlbrk() function if you use this one. Use
"install_cbrk()" instead.
int install_cbrk(void (*func)());
Installs the function "func()" to be called when ^C is hit.
You can chain a series of functions. If you use this DO NOT
use the Turbo C supplied ctrlbrk(). If argument is NULLVFP
^C exits from the program.
int remove_timer(void (*func)());
Removes "func()" from timer list. If NULLVFP is given as an
argument all timers are cleaned.
int remove_cbrk(void (*func)());
Removes "func()" from ctrlbrk list. If argument is NULLVFP
^C has no action.
RETURN VALUES:
0 => function was successfully installed or removed.
1 => Install failed because of lack of space. Compile again with a
larger NTIMER or NCBRK in "tick.h"
Remove failed because function not found.
2 => Install timer failed because we could not hook timer cleaner
onto atexit(). Try again with fewer atexit() functions.
NOTES:
* DO NOT use the Turbo C ctrlbrk() function if using these functions
- it can have quite disasterous effects. Use install_cbrk() - it
is more general in any case !.
* Both the install functions try to check if the function is already
present and do not duplicate installations.
* Define HARDTIMER in "tick.h" if you want to use the hardware
interrupt rather than the DOS 'soft' interrupt. This is at your own
peril. I have not used this.
BUGS:
Notify all bugs to :
Q3696@PUCC.BITNET or
{seismo, rutgers}\!princeton\!phoenix\!asjoshi
ACKNOWLEDGEMENTS:
Dean D. McCrory for two functions which really form the heart of the
timer portion : timer_handler, and dosbusy. The first has been
modified and made more general. It is also renamed to __tick__().
The rest of the code was written using Turbo C v1.5 entirely by me
Thanks to Borland for the wonderful (and inexpensive) C compiler.