Rev 2081 | Rev 2103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2081 | Rev 2089 | ||
|---|---|---|---|
| Line 34... | Line 34... | ||
| 34 | 34 | ||
| 35 | #ifndef KERN_TIMEOUT_H_ |
35 | #ifndef KERN_TIMEOUT_H_ |
| 36 | #define KERN_TIMEOUT_H_ |
36 | #define KERN_TIMEOUT_H_ |
| 37 | 37 | ||
| 38 | #include <arch/types.h> |
38 | #include <arch/types.h> |
| 39 | #include <cpu.h> |
- | |
| 40 | #include <synch/spinlock.h> |
- | |
| 41 | #include <adt/list.h> |
39 | #include <proc/task.h> |
| 42 | 40 | ||
| 43 | #define us2ticks(us) ((uint64_t)(((uint32_t) (us)/(1000000/HZ)))) |
41 | #define us2ticks(us) ((uint64_t) (((uint32_t) (us) / (1000000 / HZ)))) |
| 44 | - | ||
| 45 | typedef void (* timeout_handler_t)(void *arg); |
- | |
| 46 | - | ||
| 47 | typedef struct { |
- | |
| 48 | SPINLOCK_DECLARE(lock); |
- | |
| 49 | - | ||
| 50 | link_t link; /**< Link to the list of active timeouts on THE->cpu */ |
- | |
| 51 | - | ||
| 52 | uint64_t ticks; /**< Timeout will be activated in this amount of clock() ticks. */ |
- | |
| 53 | - | ||
| 54 | timeout_handler_t handler; /**< Function that will be called on timeout activation. */ |
- | |
| 55 | void *arg; /**< Argument to be passed to handler() function. */ |
- | |
| 56 | - | ||
| 57 | cpu_t *cpu; /**< On which processor is this timeout registered. */ |
- | |
| 58 | } timeout_t; |
- | |
| 59 | 42 | ||
| 60 | extern void timeout_init(void); |
43 | extern void timeout_init(void); |
| 61 | extern void timeout_initialize(timeout_t *t); |
44 | extern void timeout_initialize(timeout_t *t); |
| 62 | extern void timeout_reinitialize(timeout_t *t); |
45 | extern void timeout_reinitialize(timeout_t *t); |
| 63 | extern void timeout_register(timeout_t *t, uint64_t usec, timeout_handler_t f, void *arg); |
46 | extern void timeout_register(timeout_t *t, uint64_t usec, timeout_handler_t f, void *arg); |