1 #ifndef _linux_POSIX_TIMERS_H
2 #define _linux_POSIX_TIMERS_H
4 #include <linux/spinlock.h>
5 #include <linux/list.h>
6 #include <linux/sched.h>
10 unsigned long long sched;
13 struct cpu_timer_list {
14 struct list_head entry;
15 union cpu_time_count expires, incr;
16 struct task_struct *task;
20 #define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
21 #define CPUCLOCK_PERTHREAD(clock) \
22 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
23 #define CPUCLOCK_PID_MASK 7
24 #define CPUCLOCK_PERTHREAD_MASK 4
25 #define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
26 #define CPUCLOCK_CLOCK_MASK 3
27 #define CPUCLOCK_PROF 0
28 #define CPUCLOCK_VIRT 1
29 #define CPUCLOCK_SCHED 2
30 #define CPUCLOCK_MAX 3
32 #define MAKE_PROCESS_CPUCLOCK(pid, clock) \
33 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
34 #define MAKE_THREAD_CPUCLOCK(tid, clock) \
35 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
37 /* POSIX.1b interval timer structure. */
39 struct list_head list; /* free/ allocate list */
41 clockid_t it_clock; /* which timer type */
42 timer_t it_id; /* timer id */
43 int it_overrun; /* overrun on pending signal */
44 int it_overrun_last; /* overrun on last delivered signal */
45 int it_requeue_pending; /* waiting to requeue this timer */
46 #define REQUEUE_PENDING 1
47 int it_sigev_notify; /* notify word of sigevent struct */
48 int it_sigev_signo; /* signo word of sigevent struct */
49 sigval_t it_sigev_value; /* value word of sigevent struct */
50 struct task_struct *it_process; /* process to send signal to */
51 struct sigqueue *sigq; /* signal queue entry. */
54 struct timer_list timer;
55 struct list_head abs_timer_entry; /* clock abs_timer_list */
56 struct timespec wall_to_prev; /* wall_to_monotonic used when set */
57 unsigned long incr; /* interval in jiffies */
59 struct cpu_timer_list cpu;
64 unsigned long expires;
70 struct list_head list;
74 int res; /* in nano seconds */
75 int (*clock_getres) (clockid_t which_clock, struct timespec *tp);
76 struct k_clock_abs *abs_struct;
77 int (*clock_set) (clockid_t which_clock, struct timespec * tp);
78 int (*clock_get) (clockid_t which_clock, struct timespec * tp);
79 int (*timer_create) (struct k_itimer *timer);
80 int (*nsleep) (clockid_t which_clock, int flags, struct timespec *);
81 int (*timer_set) (struct k_itimer * timr, int flags,
82 struct itimerspec * new_setting,
83 struct itimerspec * old_setting);
84 int (*timer_del) (struct k_itimer * timr);
86 void (*timer_get) (struct k_itimer * timr,
87 struct itimerspec * cur_setting);
90 void register_posix_clock(clockid_t clock_id, struct k_clock *new_clock);
92 /* Error handlers for timer_create, nanosleep and settime */
93 int do_posix_clock_notimer_create(struct k_itimer *timer);
94 int do_posix_clock_nonanosleep(clockid_t, int flags, struct timespec *);
95 int do_posix_clock_nosettime(clockid_t, struct timespec *tp);
97 /* function to call to trigger timer event */
98 int posix_timer_event(struct k_itimer *timr, int si_private);
101 unsigned long jiffies;
104 #define posix_get_now(now) (now)->jiffies = jiffies;
105 #define posix_time_before(timer, now) \
106 time_before((timer)->expires, (now)->jiffies)
108 #define posix_bump_timer(timr, now) \
111 delta = now.jiffies - (timr)->it.real.timer.expires; \
113 orun = 1 + (delta / (timr)->it.real.incr); \
114 (timr)->it.real.timer.expires += \
115 orun * (timr)->it.real.incr; \
116 (timr)->it_overrun += orun; \
120 int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *);
121 int posix_cpu_clock_get(clockid_t which_clock, struct timespec *);
122 int posix_cpu_clock_set(clockid_t which_clock, const struct timespec *tp);
123 int posix_cpu_timer_create(struct k_itimer *);
124 int posix_cpu_nsleep(clockid_t, int, struct timespec *);
125 int posix_cpu_timer_set(struct k_itimer *, int,
126 struct itimerspec *, struct itimerspec *);
127 int posix_cpu_timer_del(struct k_itimer *);
128 void posix_cpu_timer_get(struct k_itimer *, struct itimerspec *);
130 void posix_cpu_timer_schedule(struct k_itimer *);
132 void run_posix_cpu_timers(struct task_struct *);
133 void posix_cpu_timers_exit(struct task_struct *);
134 void posix_cpu_timers_exit_group(struct task_struct *);
136 void set_process_cpu_timer(struct task_struct *, unsigned int,
137 cputime_t *, cputime_t *);