~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/posix-timers.h

Version: ~ [ linux-5.3 ] ~ [ linux-5.2.15 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.73 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.144 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.193 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.193 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.73 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _linux_POSIX_TIMERS_H
  2 #define _linux_POSIX_TIMERS_H
  3 
  4 #include <linux/spinlock.h>
  5 #include <linux/list.h>
  6 #include <linux/sched.h>
  7 #include <linux/timex.h>
  8 #include <linux/alarmtimer.h>
  9 
 10 
 11 struct cpu_timer_list {
 12         struct list_head entry;
 13         u64 expires, incr;
 14         struct task_struct *task;
 15         int firing;
 16 };
 17 
 18 /*
 19  * Bit fields within a clockid:
 20  *
 21  * The most significant 29 bits hold either a pid or a file descriptor.
 22  *
 23  * Bit 2 indicates whether a cpu clock refers to a thread or a process.
 24  *
 25  * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
 26  *
 27  * A clockid is invalid if bits 2, 1, and 0 are all set.
 28  */
 29 #define CPUCLOCK_PID(clock)             ((pid_t) ~((clock) >> 3))
 30 #define CPUCLOCK_PERTHREAD(clock) \
 31         (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
 32 
 33 #define CPUCLOCK_PERTHREAD_MASK 4
 34 #define CPUCLOCK_WHICH(clock)   ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
 35 #define CPUCLOCK_CLOCK_MASK     3
 36 #define CPUCLOCK_PROF           0
 37 #define CPUCLOCK_VIRT           1
 38 #define CPUCLOCK_SCHED          2
 39 #define CPUCLOCK_MAX            3
 40 #define CLOCKFD                 CPUCLOCK_MAX
 41 #define CLOCKFD_MASK            (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
 42 
 43 #define MAKE_PROCESS_CPUCLOCK(pid, clock) \
 44         ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
 45 #define MAKE_THREAD_CPUCLOCK(tid, clock) \
 46         MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
 47 
 48 #define FD_TO_CLOCKID(fd)       ((~(clockid_t) (fd) << 3) | CLOCKFD)
 49 #define CLOCKID_TO_FD(clk)      ((unsigned int) ~((clk) >> 3))
 50 
 51 /* POSIX.1b interval timer structure. */
 52 struct k_itimer {
 53         struct list_head list;          /* free/ allocate list */
 54         struct hlist_node t_hash;
 55         spinlock_t it_lock;
 56         clockid_t it_clock;             /* which timer type */
 57         timer_t it_id;                  /* timer id */
 58         int it_overrun;                 /* overrun on pending signal  */
 59         int it_overrun_last;            /* overrun on last delivered signal */
 60         int it_requeue_pending;         /* waiting to requeue this timer */
 61 #define REQUEUE_PENDING 1
 62         int it_sigev_notify;            /* notify word of sigevent struct */
 63         struct signal_struct *it_signal;
 64         union {
 65                 struct pid *it_pid;     /* pid of process to send signal to */
 66                 struct task_struct *it_process; /* for clock_nanosleep */
 67         };
 68         struct sigqueue *sigq;          /* signal queue entry. */
 69         union {
 70                 struct {
 71                         struct hrtimer timer;
 72                         ktime_t interval;
 73                 } real;
 74                 struct cpu_timer_list cpu;
 75                 struct {
 76                         unsigned int clock;
 77                         unsigned int node;
 78                         unsigned long incr;
 79                         unsigned long expires;
 80                 } mmtimer;
 81                 struct {
 82                         struct alarm alarmtimer;
 83                         ktime_t interval;
 84                 } alarm;
 85                 struct rcu_head rcu;
 86         } it;
 87 };
 88 
 89 struct k_clock {
 90         int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
 91         int (*clock_set) (const clockid_t which_clock,
 92                           const struct timespec *tp);
 93         int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
 94         int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
 95         int (*timer_create) (struct k_itimer *timer);
 96         int (*nsleep) (const clockid_t which_clock, int flags,
 97                        struct timespec *, struct timespec __user *);
 98         long (*nsleep_restart) (struct restart_block *restart_block);
 99         int (*timer_set) (struct k_itimer * timr, int flags,
100                           struct itimerspec * new_setting,
101                           struct itimerspec * old_setting);
102         int (*timer_del) (struct k_itimer * timr);
103 #define TIMER_RETRY 1
104         void (*timer_get) (struct k_itimer * timr,
105                            struct itimerspec * cur_setting);
106 };
107 
108 extern struct k_clock clock_posix_cpu;
109 extern struct k_clock clock_posix_dynamic;
110 
111 void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock);
112 
113 /* function to call to trigger timer event */
114 int posix_timer_event(struct k_itimer *timr, int si_private);
115 
116 void posix_cpu_timer_schedule(struct k_itimer *timer);
117 
118 void run_posix_cpu_timers(struct task_struct *task);
119 void posix_cpu_timers_exit(struct task_struct *task);
120 void posix_cpu_timers_exit_group(struct task_struct *task);
121 void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
122                            u64 *newval, u64 *oldval);
123 
124 long clock_nanosleep_restart(struct restart_block *restart_block);
125 
126 void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
127 
128 #endif
129 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp