-->

Previous | Table of Contents | Next

Page 1423

Part IX:

Kernel Reference Guide

Page 1424

add_timer, del_timer, init_timer

add_timer, del_timer, init_timer—Manage event timers.

SYNOPSIS


#include <asm/param.h>

#include <linux/timer.h>

extern void add_timer(struct timer_list * timer);

extern int del_timer(struct timer_list * timer);

extern inline void init_timer(struct timer_list * timer);

DESCRIPTION

add_timer schedules an event, adding it to a linked list of events maintained by the kernel. del_timer deletes a scheduled event. timer points to a


struct timer_list {

struct timer_list *next;

struct timer_list *prev;

unsigned long expires;

unsigned long data;

void (*function)(unsigned long);

};

init_timer sets next and prev to NULL. This is required for the argument of add_timer. expires is the desired duration of the timer in jiffies, where there are HZ (typically 100) jiffies per second. When the timer expires, function is called with data as
its argument. It is the responsibility of function to delete the event. If the same function is managing several timers, the argument can be used to distinguish which one expired.

RETURN VALUE

del_timer returns zero on error—if next or prev are not NULL, but the timer was not found. del_timer also sets expires to the time remaining before the timer expires and sets next and prev to NULL. Thus, calling del_timer followed immediately by add_timer is a no-op provided a kernel tick does not occur between the two calls.

AUTHOR

Linus Torvalds

Linux 1.2.8, 31 May 1995

adjust_clock

adjust_clock—Adjusts startup time counter to tick in GMT.

SYNOPSIS


linux/kernel/sys.c

void adjust_clock();

DESCRIPTION

This routine adjusts the startup time by adding the time zone information to it. The goal is to get the startup time ticking in GMT time.

NOTE

This routine is called from settimeofday(2) when the time-zone information is first set.

Previous | Table of Contents | Next