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 struct signal_struct *it_signal;
50 struct pid *it_pid; /* pid of process to send signal to */
51 struct task_struct *it_process; /* for clock_nanosleep */
53 struct sigqueue *sigq; /* signal queue entry. */
59 struct cpu_timer_list cpu;
64 unsigned long expires;
70 int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
71 int (*clock_set) (const clockid_t which_clock,
72 const struct timespec *tp);
73 int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
74 int (*timer_create) (struct k_itimer *timer);
75 int (*nsleep) (const clockid_t which_clock, int flags,
76 struct timespec *, struct timespec __user *);
77 long (*nsleep_restart) (struct restart_block *restart_block);
78 int (*timer_set) (struct k_itimer * timr, int flags,
79 struct itimerspec * new_setting,
80 struct itimerspec * old_setting);
81 int (*timer_del) (struct k_itimer * timr);
83 void (*timer_get) (struct k_itimer * timr,
84 struct itimerspec * cur_setting);
87 extern struct k_clock clock_posix_cpu;
89 void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
91 /* function to call to trigger timer event */
92 int posix_timer_event(struct k_itimer *timr, int si_private);
94 void posix_cpu_timer_schedule(struct k_itimer *timer);
96 void run_posix_cpu_timers(struct task_struct *task);
97 void posix_cpu_timers_exit(struct task_struct *task);
98 void posix_cpu_timers_exit_group(struct task_struct *task);
100 void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
101 cputime_t *newval, cputime_t *oldval);
103 long clock_nanosleep_restart(struct restart_block *restart_block);
105 void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);