123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef KERN_TIMER_H
- #define KERN_TIMER_H
- #include <stdint.h>
- #include <kern/hlist.h>
- #include <kern/init.h>
- #include <kern/work.h>
- #define TIMER_DETACHED 0x1
- #define TIMER_INTR 0x2
- #define TIMER_HIGH_PRIO 0x4
- struct timer;
- typedef void (*timer_fn_t) (struct timer *);
- struct timer
- {
- union
- {
- struct hlist_node node;
- struct work work;
- };
- uint64_t ticks;
- timer_fn_t fn;
- unsigned int cpu;
- unsigned short state;
- unsigned short flags;
- struct thread *joiner;
- };
- static inline uint64_t
- timer_get_time (const struct timer *timer)
- {
- return (timer->ticks);
- }
- void timer_init (struct timer *timer, timer_fn_t fn, int flags);
- void timer_schedule (struct timer *timer, uint64_t ticks);
- void timer_cancel (struct timer *timer);
- void timer_report_periodic_event (void);
- INIT_OP_DECLARE (timer_bootstrap);
- #endif
|