TIMER-
The basic idea of a timer is that they allow tasks to be run at sometime in the future. When their time arrives, they are scheduled to be run. The responsibility of actually running them is then turned over to someone else, such as the scheduler. In order to communicate with the scheduler, we'll set up a common data structure called a timer.
I've also included a few other miscellaneous definitions that will be needed later on. For instance, the TIME typedef is used to declare all relative time variables. You can complete this definition based on what your needs are.
By implementing the timers as a separate piece of software, we can reduce the complexity of the scheduler. Some people like this kind of modularization, and some don't. Similarly some operating systems do this, and some don't. I like it. It makes the code easier to write, to read, and to correct (oops).
include <stdio.h>
define TRUE 1
define FALSE 0
define MAX_TIMERS ... /* number of timers */
typedef ... TIME; /* how time is actually stored */
define VERY_LONG_TIME ... /* longest time possible */
struct timer {
int inuse; /* TRUE if in use */
TIME time; /* relative time to wait */
char *event; /* set to TRUE at timeout */
} timers[MAX_TIMERS]; /* set of timers
SOURCE-http://www.kohala.com/start/libes.timers.txt