This chapter introduced the following symbols:
HZsymbol specifies the number of clock ticks generated per second.
volatile unsigned long jiffies
jiffiesvariable is incremented once for each clock tick; thus, it’s incremented
HZtimes per second.
Read the timestamp counter or its lower half. The header and macros are specific to PC-class processors; other platforms may need
asmconstructs to achieve similar results.
extern struct timeval xtime;
void do_gettimeofday(struct timeval *tv);,
void get_fast_time(struct timeval *tv);
The functions return the current time; the former is very high resolution, the latter may be faster while giving coarser resolution.
void udelay(unsigned long usecs);,
void mdelay(unsigned long msecs);
The functions introduce delays of an integer number of microseconds and milliseconds. The former should be used to wait for no longer than one millisecond; the latter should be used with extreme care because these delays are both busy-loops.
Returns nonzero if the processor is currently running in interrupt mode.
void queue_task(struct tq_struct *task, task_queue *list);
void run_task_queue(task_queue *list);
task_queue tq_immediate, tq_timer;
These predefined task queues are run as soon as possible (for
tq_immediate), or after each timer tick (for
int schedule_task(struct tq_struct *task);
DECLARE_TASKLET(name, function, data),
DECLARE_TASKLET_DISABLED(name, function, data)
Declare a tasklet structure that will call the given function (passing it the given
unsigned longdata) when the tasklet is executed. The second form initializes the tasklet to a disabled state, keeping it from running until it is explicitly enabled.
void tasklet_schedule(struct tasklet_struct *tasklet);
Schedules the given tasklet for running. If the tasklet is enabled, it will be run shortly on the same CPU that ran the first call to tasklet_schedule.
tasklet_enable(struct tasklet_struct *tasklet);,
tasklet_disable(struct tasklet_struct *tasklet);
These functions respectively enable and disable the given tasklet. A disabled tasklet can be scheduled, but will not run until it has been enabled again.
void tasklet_kill(struct tasklet_struct *tasklet);
Causes an “infinitely rescheduling” tasklet to cease execution. This function can block and may not be called in interrupt time.
void init_timer(struct timer_list * timer);
void add_timer(struct timer_list * timer);
This function inserts the
timerinto the global list of pending timers.
int mod_timer(struct timer_list *timer, unsigned long expires);
This function is used to change the expiration time of an already scheduled timer structure.
int del_timer(struct timer_list * timer);
del_timer removes a timer from the list of pending timers. If the timer was actually queued, del_timer returns 1; otherwise, it returns 0.
int del_timer_sync(struct timer_list *timer);
This function is similar to del_timer, but guarantees that the function is not currently running on other CPUs.
Get Linux Device Drivers, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.