netlib.narod.ru< Назад | Оглавление | Далее >

include/linux/timer.h

18419 #ifndef _LINUX_TIMER_H
18420 #define _LINUX_TIMER_H
18421 
18422 /* Old-style timers. Please don't use for any new code.
18423  *
18424  * Numbering of these timers should be consecutive to
18425  * minimize processing delays. [MJ] */
18426 
18427 #define BLANK_TIMER      0 /* Console screen-saver */
18428 #define BEEP_TIMER       1 /* Console beep */
18429 #define RS_TIMER         2 /* RS-232 ports */
18430 #define SWAP_TIMER       3 /* Background pageout */
18431 #define BACKGR_TIMER     4 /* io_request background I/O*/
18432 #define HD_TIMER         5 /* Old IDE driver */
18433 #define FLOPPY_TIMER     6 /* Floppy */
18434 #define QIC02_TAPE_TIMER 7 /* QIC 02 tape */
18435 #define MCD_TIMER        8 /* Mitsumi CDROM */
18436 #define GSCD_TIMER       9 /* Goldstar CDROM */
18437 #define COMTROL_TIMER   10 /* Comtrol serial */
18438 #define DIGI_TIMER      11 /* Digi serial */
18439 #define GDTH_TIMER      12 /* Ugh - gdth scsi driver */
18440 
18441 #define COPRO_TIMER     31 /* 387 timeout for buggy
18442                               hardware (boot only) */
18443 
18444 struct timer_struct {
18445   unsigned long expires;
18446   void (*fn)(void);
18447 };
18448 
18449 extern unsigned long timer_active;
18450 extern struct timer_struct timer_table[32];
18451 
18452 /* This is completely separate from the above, and is the
18453  * "new and improved" way of handling timers more
18454  * dynamically.  Hopefully efficient and general enough
18455  * for most things.
18456  *
18457  * The "hardcoded" timers above are still useful for
18458  * well- defined problems, but the timer-list is probably
18459  * better when you need multiple outstanding timers or
18460  * similar.
18461  *
18462  * The "data" field is in case you want to use the same
18463  * timeout function for several timeouts. You can use
18464  * this to distinguish between the different invocations.
18465  */
18466 struct timer_list {
18467   struct timer_list *next; /* MUST be first element */
18468   struct timer_list *prev;
18469   unsigned long expires;
18470   unsigned long data;
18471   void (*function)(unsigned long);
18472 };
18473 
18474 extern void add_timer(struct timer_list * timer);
18475 extern int  del_timer(struct timer_list * timer);
18476 
18477 /* mod_timer is a more efficient way to update the expire
18478  * field of an active timer (if the timer is inactive it
18479  * will be activated)
18480  * mod_timer(a,b) is equivalent to
18481  * del_timer(a); a->expires = b; add_timer(a) */
18482 void mod_timer(struct timer_list *timer,
18483                unsigned long expires);
18484 
18485 extern void it_real_fn(unsigned long);
18486 
18487 extern inline void init_timer(struct timer_list * timer)
18488 {
18489   timer->next = NULL;
18490   timer->prev = NULL;
18491 }
18492 
18493 extern inline int
18494 timer_pending(struct timer_list * timer)
18495 {
18496   return timer->prev != NULL;
18497 }
18498 
18499 /* These inlines deal with timer wrapping correctly. You
18500  * are strongly encouraged to use them
18501  *      1. Because people otherwise forget
18502  *      2. Because if the timer wrap changes in future
18503  *         you wont have to alter your driver code.
18504  *
18505  * Do this with "<0" and ">=0" to only test the sign of
18506  * the result. A good compiler would generate better code
18507  * (and a really good compiler wouldn't care). Gcc is
18508  * currently neither.  */
18509 #define time_after(a,b)      ((long)(b) - (long)(a) < 0)
18510 #define time_before(a,b)     time_after(b,a)
18511 
18512 #define time_after_eq(a,b)   ((long)(a) - (long)(b) >= 0)
18513 #define time_before_eq(a,b)  time_after_eq(b,a)
18514 
18515 #endif

netlib.narod.ru< Назад | Оглавление | Далее >

Сайт управляется системой uCoz