timer.c File Reference

Go to the source code of this file.

Classes

struct  tvec
struct  tvec_root
struct  tvec_base

Defines

#define TVN_BITS   (CONFIG_BASE_SMALL ? 4 : 6)
#define TVR_BITS   (CONFIG_BASE_SMALL ? 6 : 8)
#define TVN_SIZE   (1 << TVN_BITS)
#define TVR_SIZE   (1 << TVR_BITS)
#define TVN_MASK   (TVN_SIZE - 1)
#define TVR_MASK   (TVR_SIZE - 1)
#define TBASE_DEFERRABLE_FLAG   (0x1)
#define INDEX(N)   ((base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK)

Functions

 EXPORT_SYMBOL (jiffies_64)
 EXPORT_SYMBOL (boot_tvec_bases)
static DEFINE_PER_CPU (struct tvec_base *, tvec_bases)
static unsigned int tbase_get_deferrable (struct tvec_base *base)
static struct tvec_basetbase_get_base (struct tvec_base *base)
static void timer_set_deferrable (struct timer_list *timer)
static void timer_set_base (struct timer_list *timer, struct tvec_base *new_base)
static unsigned long round_jiffies_common (unsigned long j, int cpu, bool force_up)
unsigned long __round_jiffies (unsigned long j, int cpu)
 __round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen
 EXPORT_SYMBOL_GPL (__round_jiffies)
unsigned long __round_jiffies_relative (unsigned long j, int cpu)
 __round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen
 EXPORT_SYMBOL_GPL (__round_jiffies_relative)
unsigned long round_jiffies (unsigned long j)
 round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded
 EXPORT_SYMBOL_GPL (round_jiffies)
unsigned long round_jiffies_relative (unsigned long j)
 round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded
 EXPORT_SYMBOL_GPL (round_jiffies_relative)
unsigned long __round_jiffies_up (unsigned long j, int cpu)
 __round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen
 EXPORT_SYMBOL_GPL (__round_jiffies_up)
unsigned long __round_jiffies_up_relative (unsigned long j, int cpu)
 __round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen
 EXPORT_SYMBOL_GPL (__round_jiffies_up_relative)
unsigned long round_jiffies_up (unsigned long j)
 round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded
 EXPORT_SYMBOL_GPL (round_jiffies_up)
unsigned long round_jiffies_up_relative (unsigned long j)
 round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded
 EXPORT_SYMBOL_GPL (round_jiffies_up_relative)
static void set_running_timer (struct tvec_base *base, struct timer_list *timer)
static void internal_add_timer (struct tvec_base *base, struct timer_list *timer)
static void timer_stats_account_timer (struct timer_list *timer)
static void debug_timer_init (struct timer_list *timer)
static void debug_timer_activate (struct timer_list *timer)
static void debug_timer_deactivate (struct timer_list *timer)
static void __init_timer (struct timer_list *timer)
void init_timer (struct timer_list *timer)
 init_timer - initialize a timer.
 EXPORT_SYMBOL (init_timer)
void init_timer_deferrable (struct timer_list *timer)
 EXPORT_SYMBOL (init_timer_deferrable)
static void detach_timer (struct timer_list *timer, int clear_pending)
static struct tvec_baselock_timer_base (struct timer_list *timer, unsigned long *flags) __acquires(timer->base->lock)
int __mod_timer (struct timer_list *timer, unsigned long expires)
 EXPORT_SYMBOL (__mod_timer)
void add_timer_on (struct timer_list *timer, int cpu)
 add_timer_on - start a timer on a particular CPU : the timer to be added : the CPU to start it on
int mod_timer (struct timer_list *timer, unsigned long expires)
 mod_timer - modify a timer's timeout : the timer to be modified : new timeout in jiffies
 EXPORT_SYMBOL (mod_timer)
int del_timer (struct timer_list *timer)
 del_timer - deactive a timer.
 EXPORT_SYMBOL (del_timer)
static int cascade (struct tvec_base *base, struct tvec *tv, int index)
static void __run_timers (struct tvec_base *base)
 __run_timers - run all expired timers (if any) on this CPU.
void update_process_times (int user_tick)
static unsigned long count_active_tasks (void)
 EXPORT_SYMBOL (avenrun)
static void calc_load (unsigned long ticks)
static void run_timer_softirq (struct softirq_action *h)
void run_local_timers (void)
static void update_times (unsigned long ticks)
void do_timer (unsigned long ticks)
 SYSCALL_DEFINE0 (getpid)
 sys_getpid - return the thread group id of the current process
 SYSCALL_DEFINE0 (getppid)
 SYSCALL_DEFINE0 (getuid)
 SYSCALL_DEFINE0 (geteuid)
 SYSCALL_DEFINE0 (getgid)
 SYSCALL_DEFINE0 (getegid)
static void process_timeout (unsigned long __data)
signed long __sched schedule_timeout (signed long timeout)
 schedule_timeout - sleep until timeout : timeout value in jiffies
 EXPORT_SYMBOL (schedule_timeout)
signed long __sched schedule_timeout_interruptible (signed long timeout)
 EXPORT_SYMBOL (schedule_timeout_interruptible)
signed long __sched schedule_timeout_killable (signed long timeout)
 EXPORT_SYMBOL (schedule_timeout_killable)
signed long __sched schedule_timeout_uninterruptible (signed long timeout)
 EXPORT_SYMBOL (schedule_timeout_uninterruptible)
 SYSCALL_DEFINE0 (gettid)
int do_sysinfo (struct sysinfo *info)
 do_sysinfo - fill in sysinfo struct : pointer to buffer to fill
 SYSCALL_DEFINE1 (sysinfo, struct sysinfo __user *, info)
static int __cpuinit init_timers_cpu (int cpu)
static int __cpuinit timer_cpu_notify (struct notifier_block *self, unsigned long action, void *hcpu)
void __init init_timers (void)
void msleep (unsigned int msecs)
 msleep - sleep safely even with waitqueue interruptions : Time in milliseconds to sleep for
 EXPORT_SYMBOL (msleep)
unsigned long msleep_interruptible (unsigned int msecs)
 msleep_interruptible - sleep waiting for signals : Time in milliseconds to sleep for
 EXPORT_SYMBOL (msleep_interruptible)

Variables

u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES
struct tvec_base ____cacheline_aligned
struct tvec_base boot_tvec_bases
unsigned long avenrun [3]
static struct notifier_block
__cpuinitdata 
timers_nb


Define Documentation

#define INDEX (  )     ((base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK)

Definition at line 827 of file linux26/lib/src/kernel/timer.c.

#define TBASE_DEFERRABLE_FLAG   (0x1)

Definition at line 91 of file linux26/lib/src/kernel/timer.c.

#define TVN_BITS   (CONFIG_BASE_SMALL ? 4 : 6)

Definition at line 56 of file linux26/lib/src/kernel/timer.c.

#define TVN_MASK   (TVN_SIZE - 1)

Definition at line 60 of file linux26/lib/src/kernel/timer.c.

#define TVN_SIZE   (1 << TVN_BITS)

Definition at line 58 of file linux26/lib/src/kernel/timer.c.

#define TVR_BITS   (CONFIG_BASE_SMALL ? 6 : 8)

Definition at line 57 of file linux26/lib/src/kernel/timer.c.

#define TVR_MASK   (TVR_SIZE - 1)

Definition at line 61 of file linux26/lib/src/kernel/timer.c.

#define TVR_SIZE   (1 << TVR_BITS)

Definition at line 59 of file linux26/lib/src/kernel/timer.c.


Function Documentation

static void __init_timer ( struct timer_list timer  )  [static]

Definition at line 519 of file linux26/lib/src/kernel/timer.c.

int __mod_timer ( struct timer_list timer,
unsigned long  expires 
)

Definition at line 596 of file linux26/lib/src/kernel/timer.c.

unsigned long __round_jiffies ( unsigned long  j,
int  cpu 
)

__round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen

__round_jiffies() rounds an absolute time in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.

The return value is the rounded version of the parameter.

Definition at line 176 of file linux26/lib/src/kernel/timer.c.

unsigned long __round_jiffies_relative ( unsigned long  j,
int  cpu 
)

__round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen

__round_jiffies_relative() rounds a time delta in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.

The return value is the rounded version of the parameter.

Definition at line 202 of file linux26/lib/src/kernel/timer.c.

unsigned long __round_jiffies_up ( unsigned long  j,
int  cpu 
)

__round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen

This is the same as __round_jiffies() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 263 of file linux26/lib/src/kernel/timer.c.

unsigned long __round_jiffies_up_relative ( unsigned long  j,
int  cpu 
)

__round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen

This is the same as __round_jiffies_relative() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 279 of file linux26/lib/src/kernel/timer.c.

static void __run_timers ( struct tvec_base base  )  [inline, static]

__run_timers - run all expired timers (if any) on this CPU.

: the timer vector to be processed.

This function cascades all vectors and executes all expired timer vectors.

Definition at line 836 of file linux26/lib/src/kernel/timer.c.

void add_timer_on ( struct timer_list timer,
int  cpu 
)

add_timer_on - start a timer on a particular CPU : the timer to be added : the CPU to start it on

This is not very scalable on SMP. Double adds are not possible.

Definition at line 650 of file linux26/lib/src/kernel/timer.c.

static void calc_load ( unsigned long  ticks  )  [inline, static]

Definition at line 1068 of file linux26/lib/src/kernel/timer.c.

static int cascade ( struct tvec_base base,
struct tvec tv,
int  index 
) [static]

Definition at line 807 of file linux26/lib/src/kernel/timer.c.

static unsigned long count_active_tasks ( void   )  [static]

Definition at line 1047 of file linux26/lib/src/kernel/timer.c.

static void debug_timer_activate ( struct timer_list timer  )  [inline, static]

Definition at line 515 of file linux26/lib/src/kernel/timer.c.

static void debug_timer_deactivate ( struct timer_list timer  )  [inline, static]

Definition at line 516 of file linux26/lib/src/kernel/timer.c.

static void debug_timer_init ( struct timer_list timer  )  [inline, static]

Definition at line 514 of file linux26/lib/src/kernel/timer.c.

static DEFINE_PER_CPU ( struct tvec_base ,
tvec_bases   
) [static]

int del_timer ( struct timer_list timer  ) 

del_timer - deactive a timer.

: the timer to be deactivated

del_timer() deactivates a timer - this works on both active and inactive timers.

The function returns whether it has deactivated a pending timer or not. (ie. del_timer() of an inactive timer returns 0, del_timer() of an active timer returns 1.)

Definition at line 722 of file linux26/lib/src/kernel/timer.c.

static void detach_timer ( struct timer_list timer,
int  clear_pending 
) [inline, static]

Definition at line 551 of file linux26/lib/src/kernel/timer.c.

int do_sysinfo ( struct sysinfo *  info  ) 

do_sysinfo - fill in sysinfo struct : pointer to buffer to fill

Definition at line 1324 of file linux26/lib/src/kernel/timer.c.

void do_timer ( unsigned long  ticks  ) 

Definition at line 1124 of file linux26/lib/src/kernel/timer.c.

EXPORT_SYMBOL ( msleep_interruptible   ) 

EXPORT_SYMBOL ( msleep   ) 

EXPORT_SYMBOL ( schedule_timeout_uninterruptible   ) 

EXPORT_SYMBOL ( schedule_timeout_killable   ) 

EXPORT_SYMBOL ( schedule_timeout_interruptible   ) 

EXPORT_SYMBOL ( schedule_timeout   ) 

EXPORT_SYMBOL ( avenrun   ) 

EXPORT_SYMBOL ( del_timer   ) 

EXPORT_SYMBOL ( mod_timer   ) 

EXPORT_SYMBOL ( __mod_timer   ) 

EXPORT_SYMBOL ( init_timer_deferrable   ) 

EXPORT_SYMBOL ( init_timer   ) 

EXPORT_SYMBOL ( boot_tvec_bases   ) 

EXPORT_SYMBOL ( jiffies_64   ) 

EXPORT_SYMBOL_GPL ( round_jiffies_up_relative   ) 

EXPORT_SYMBOL_GPL ( round_jiffies_up   ) 

EXPORT_SYMBOL_GPL ( __round_jiffies_up_relative   ) 

EXPORT_SYMBOL_GPL ( __round_jiffies_up   ) 

EXPORT_SYMBOL_GPL ( round_jiffies_relative   ) 

EXPORT_SYMBOL_GPL ( round_jiffies   ) 

EXPORT_SYMBOL_GPL ( __round_jiffies_relative   ) 

EXPORT_SYMBOL_GPL ( __round_jiffies   ) 

void init_timer ( struct timer_list timer  ) 

init_timer - initialize a timer.

: the timer to be initialized

init_timer() must be done to a timer prior calling *any* of the other timer functions.

Definition at line 537 of file linux26/lib/src/kernel/timer.c.

void init_timer_deferrable ( struct timer_list timer  ) 

Definition at line 544 of file linux26/lib/src/kernel/timer.c.

void __init init_timers ( void   ) 

Definition at line 1548 of file linux26/lib/src/kernel/timer.c.

static int __cpuinit init_timers_cpu ( int  cpu  )  [static]

Definition at line 1419 of file linux26/lib/src/kernel/timer.c.

static void internal_add_timer ( struct tvec_base base,
struct timer_list timer 
) [static]

Definition at line 328 of file linux26/lib/src/kernel/timer.c.

static struct tvec_base* lock_timer_base ( struct timer_list timer,
unsigned long *  flags 
) [static, read]

Definition at line 576 of file linux26/lib/src/kernel/timer.c.

int mod_timer ( struct timer_list timer,
unsigned long  expires 
)

mod_timer - modify a timer's timeout : the timer to be modified : new timeout in jiffies

mod_timer() is a more efficient way to update the expire field of an active timer (if the timer is inactive it will be activated)

mod_timer(timer, expires) is equivalent to:

del_timer(timer); timer->expires = expires; add_timer(timer);

Note that if there are multiple unserialized concurrent users of the same timer, then mod_timer() is the only safe way to modify the timeout, since add_timer() cannot modify an already running timer.

The function returns whether it has modified a pending timer or not. (ie. mod_timer() of an inactive timer returns 0, mod_timer() of an active timer returns 1.)

Definition at line 693 of file linux26/lib/src/kernel/timer.c.

void msleep ( unsigned int  msecs  ) 

msleep - sleep safely even with waitqueue interruptions : Time in milliseconds to sleep for

Definition at line 1564 of file linux26/lib/src/kernel/timer.c.

unsigned long msleep_interruptible ( unsigned int  msecs  ) 

msleep_interruptible - sleep waiting for signals : Time in milliseconds to sleep for

Definition at line 1579 of file linux26/lib/src/kernel/timer.c.

static void process_timeout ( unsigned long  __data  )  [static]

Definition at line 1207 of file linux26/lib/src/kernel/timer.c.

unsigned long round_jiffies ( unsigned long  j  ) 

round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded

round_jiffies() rounds an absolute time in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The return value is the rounded version of the parameter.

Definition at line 226 of file linux26/lib/src/kernel/timer.c.

static unsigned long round_jiffies_common ( unsigned long  j,
int  cpu,
bool  force_up 
) [static]

Definition at line 118 of file linux26/lib/src/kernel/timer.c.

unsigned long round_jiffies_relative ( unsigned long  j  ) 

round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded

round_jiffies_relative() rounds a time delta in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The return value is the rounded version of the parameter.

Definition at line 247 of file linux26/lib/src/kernel/timer.c.

unsigned long round_jiffies_up ( unsigned long  j  ) 

round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded

This is the same as round_jiffies() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 297 of file linux26/lib/src/kernel/timer.c.

unsigned long round_jiffies_up_relative ( unsigned long  j  ) 

round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded

This is the same as round_jiffies_relative() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 312 of file linux26/lib/src/kernel/timer.c.

void run_local_timers ( void   ) 

Definition at line 1101 of file linux26/lib/src/kernel/timer.c.

static void run_timer_softirq ( struct softirq_action *  h  )  [static]

Definition at line 1088 of file linux26/lib/src/kernel/timer.c.

signed long __sched schedule_timeout ( signed long  timeout  ) 

schedule_timeout - sleep until timeout : timeout value in jiffies

Make the current task sleep until jiffies have elapsed. The routine will return immediately unless the current task state has been set (see set_current_state()).

You can set the task state as follows -

TASK_UNINTERRUPTIBLE - at least jiffies are guaranteed to pass before the routine returns. The routine will return 0

TASK_INTERRUPTIBLE - the routine may return early if a signal is delivered to the current task. In this case the remaining time in jiffies will be returned, or 0 if the timer expired in time

The current task state is guaranteed to be TASK_RUNNING when this routine returns.

Specifying a value of MAX_SCHEDULE_TIMEOUT will schedule the CPU away without a bound on the timeout. In this case the return value will be MAX_SCHEDULE_TIMEOUT.

In all cases the return value is guaranteed to be non-negative.

Definition at line 1238 of file linux26/lib/src/kernel/timer.c.

signed long __sched schedule_timeout_interruptible ( signed long  timeout  ) 

Definition at line 1293 of file linux26/lib/src/kernel/timer.c.

signed long __sched schedule_timeout_killable ( signed long  timeout  ) 

Definition at line 1300 of file linux26/lib/src/kernel/timer.c.

signed long __sched schedule_timeout_uninterruptible ( signed long  timeout  ) 

Definition at line 1307 of file linux26/lib/src/kernel/timer.c.

static void set_running_timer ( struct tvec_base base,
struct timer_list timer 
) [inline, static]

Definition at line 320 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( gettid   ) 

Definition at line 1315 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( getegid   ) 

Definition at line 1199 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( getgid   ) 

Definition at line 1193 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( geteuid   ) 

Definition at line 1187 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( getuid   ) 

Definition at line 1181 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( getppid   ) 

Definition at line 1170 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE0 ( getpid   ) 

sys_getpid - return the thread group id of the current process

Note, despite the name, this returns the tgid not the pid. The tgid and the pid are identical unless CLONE_THREAD was specified on clone() in which case the tgid is the same in all threads of the same group.

This is SMP safe as current->tgid does not change.

Definition at line 1159 of file linux26/lib/src/kernel/timer.c.

SYSCALL_DEFINE1 ( sysinfo  ,
struct sysinfo __user *  ,
info   
)

Definition at line 1407 of file linux26/lib/src/kernel/timer.c.

static struct tvec_base* tbase_get_base ( struct tvec_base base  )  [static, read]

Definition at line 99 of file linux26/lib/src/kernel/timer.c.

static unsigned int tbase_get_deferrable ( struct tvec_base base  )  [inline, static]

Definition at line 94 of file linux26/lib/src/kernel/timer.c.

static int __cpuinit timer_cpu_notify ( struct notifier_block *  self,
unsigned long  action,
void *  hcpu 
) [static]

Definition at line 1521 of file linux26/lib/src/kernel/timer.c.

static void timer_set_base ( struct timer_list timer,
struct tvec_base new_base 
) [inline, static]

Definition at line 111 of file linux26/lib/src/kernel/timer.c.

static void timer_set_deferrable ( struct timer_list timer  )  [inline, static]

Definition at line 104 of file linux26/lib/src/kernel/timer.c.

static void timer_stats_account_timer ( struct timer_list timer  )  [static]

Definition at line 393 of file linux26/lib/src/kernel/timer.c.

void update_process_times ( int  user_tick  ) 

Definition at line 1029 of file linux26/lib/src/kernel/timer.c.

static void update_times ( unsigned long  ticks  )  [inline, static]

Definition at line 1112 of file linux26/lib/src/kernel/timer.c.


Variable Documentation

u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES

Definition at line 49 of file linux26/lib/src/kernel/timer.c.

unsigned long avenrun[3]

Definition at line 1060 of file linux26/lib/src/kernel/timer.c.

Definition at line 82 of file linux26/lib/src/kernel/timer.c.

struct notifier_block __cpuinitdata timers_nb [static]

Initial value:

 {
        .notifier_call  = timer_cpu_notify,
}

Definition at line 1543 of file linux26/lib/src/kernel/timer.c.


Generated on Wed Apr 11 06:39:16 2012 for DDE - The L4 Device Driver Environment by  doxygen 1.5.6