timer.c File Reference

Timer handling. More...

#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include "timer.h"
#include "dprint.h"
#include "error.h"
#include "pt.h"
#include "config.h"
#include "sr_module.h"
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include <stdlib.h>

Include dependency graph for timer.c:

Go to the source code of this file.

Data Structures

struct  sr_timer_process

Functions

int count_timer_procs (void)
 Counts the timer processes that needs to be created.
void destroy_timer (void)
 Free timers.
unsigned int get_ticks (void)
 Return the actual tick count.
utime_t get_uticks (void)
 Return the actual utick count.
int init_timer (void)
 Initialize the timers, allocate jiffies and ujiffies in shared memory.
static struct sr_timernew_sr_timer (timer_function f, void *param, unsigned int interval)
 Create a new timer, allocated in private memory.
static struct sr_timer_processnew_timer_process_list (unsigned int flags)
 Create a new timer process list in private memory.
int register_timer (timer_function f, void *param, unsigned int interval)
 register a periodic timer;
int register_timer_process (timer_function f, void *param, unsigned int interval, unsigned int flags)
 register a timer process
int register_utimer (utimer_function f, void *param, unsigned int interval)
 register a periodic utimer;
static void run_timer_process (struct sr_timer_process *tpl, int do_jiffies)
 Run a timer process.
int start_timer_processes (void)
 Start timer processes.
static void timer_ticker (struct sr_timer *timer_list)
 Process all timer on the list.
static void utimer_ticker (struct sr_timer *utimer_list)
 Process all utimer on the list.

Variables

static unsigned int * jiffies = 0
static unsigned int timer_id = 0
static struct sr_timer_processtimer_proc_list = 0
static utime_tujiffies = 0


Detailed Description

Timer handling.

Definition in file timer.c.


Function Documentation

int count_timer_procs ( void   ) 

Counts the timer processes that needs to be created.

Returns:
number of necessary timer processes

Definition at line 415 of file timer.c.

References sr_timer_process::next, NULL, sr_timer_process::timer_list, and sr_timer_process::utimer_list.

Referenced by init_multi_proc_support().

void destroy_timer ( void   ) 

Free timers.

Definition at line 135 of file timer.c.

References jiffies, shm_free, and ujiffies.

Referenced by cleanup().

unsigned int get_ticks ( void   ) 

utime_t get_uticks ( void   ) 

Return the actual utick count.

Definition at line 248 of file timer.c.

References LM_CRIT, and ujiffies.

Referenced by set_1timer(), and set_timer().

int init_timer ( void   ) 

Initialize the timers, allocate jiffies and ujiffies in shared memory.

Returns:
0 on success, negative result on error

Definition at line 99 of file timer.c.

References E_CFG, E_OUT_OF_MEM, jiffies, LM_CRIT, LM_ERR, new_timer_process_list(), NULL, shm_malloc(), TIMER_PROC_INIT_FLAG, TIMER_TICK, ujiffies, and UTIMER_TICK.

Referenced by main().

static struct sr_timer* new_sr_timer ( timer_function  f,
void *  param,
unsigned int  interval 
) [static, read]

Create a new timer, allocated in private memory.

Returns:
NULL on error, a pointer to the new timer on success

Definition at line 148 of file timer.c.

References sr_timer::expires, sr_timer::id, sr_timer::interval, jiffies, LM_ERR, NULL, pkg_malloc, sr_timer::t_param, sr_timer::timer_f, timer_id, and sr_timer::u.

Referenced by register_timer(), register_timer_process(), and register_utimer().

static struct sr_timer_process* new_timer_process_list ( unsigned int  flags  )  [static, read]

Create a new timer process list in private memory.

Definition at line 71 of file timer.c.

References sr_timer_process::flags, LM_ERR, sr_timer_process::next, NULL, and pkg_malloc.

Referenced by init_timer(), and register_timer_process().

int register_timer ( timer_function  f,
void *  param,
unsigned int  interval 
)

register a periodic timer;

Note:
If you need it in a module, register it from mod_init or it won't work otherwise
Returns:
negative result on error, the timer id on success

Definition at line 173 of file timer.c.

References E_OUT_OF_MEM, sr_timer::id, new_sr_timer(), sr_timer::next, NULL, and sr_timer_process::timer_list.

Referenced by init_black_lists(), init_dlg_db(), initialize_kill(), mod_init(), and pike_init().

int register_timer_process ( timer_function  f,
void *  param,
unsigned int  interval,
unsigned int  flags 
)

register a timer process

Returns:
negative result on error, the timer id on success

Definition at line 211 of file timer.c.

References E_OUT_OF_MEM, sr_timer::id, new_sr_timer(), new_timer_process_list(), sr_timer::next, NULL, and sr_timer_process::timer_list.

Referenced by mod_init().

int register_utimer ( utimer_function  f,
void *  param,
unsigned int  interval 
)

register a periodic utimer;

Note:
If you need it in a module, register it from mod_init or it won't work otherwise
Returns:
negative result on error, the timer id on success

Definition at line 193 of file timer.c.

References E_OUT_OF_MEM, sr_timer::id, new_sr_timer(), sr_timer::next, NULL, and sr_timer_process::utimer_list.

Referenced by mod_init().

static void run_timer_process ( struct sr_timer_process tpl,
int  do_jiffies 
) [static]

int start_timer_processes ( void   ) 

static void timer_ticker ( struct sr_timer timer_list  )  [inline, static]

Process all timer on the list.

Definition at line 261 of file timer.c.

References sr_timer::expires, sr_timer::interval, jiffies, sr_timer::next, sr_timer::t_param, sr_timer::timer_f, TIMER_TICK, and sr_timer::u.

Referenced by run_timer_process().

static void utimer_ticker ( struct sr_timer utimer_list  )  [inline, static]

Process all utimer on the list.

Definition at line 291 of file timer.c.

References sr_timer::expires, sr_timer::interval, sr_timer::next, sr_timer::t_param, sr_timer::u, ujiffies, sr_timer::utimer_f, and UTIMER_TICK.

Referenced by run_timer_process().


Variable Documentation

unsigned int* jiffies = 0 [static]

unsigned int timer_id = 0 [static]

Definition at line 65 of file timer.c.

Referenced by new_sr_timer().

struct sr_timer_process* timer_proc_list = 0 [static]

List of all timer processes

Definition at line 61 of file timer.c.

utime_t* ujiffies = 0 [static]

Definition at line 64 of file timer.c.

Referenced by destroy_timer(), get_uticks(), init_timer(), run_timer_process(), and utimer_ticker().


Generated on Thu May 24 20:00:44 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6