Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

/opentcp/timers.c File Reference


Detailed Description

Author:
Version:
1.0
Date:
18.7.2001
Bug:
Warning:
Todo:

OpenTCP implementation of a timer pool used by all applications.

Definition in file timers.c.

Go to the source code of this file.

Functions

void timer_pool_init (void)
 Initialize timer pool.

UINT8 get_timer (void)
 Obtain a timer from timer pool.

void free_timer (UINT8 nbr)
 Release timer back to free timer pool.

void init_timer (UINT8 nbr, UINT32 tout)
 Initialize timer to a given time-out value.

UINT32 check_timer (UINT8 nbr)
 Return the value of a given timer.

void decrement_timers (void)
 Decrement all timers' values by one.


Variables

struct {
timer_pool [NUMTIMERS]
 Timer pool used to keep information about available timers.


Function Documentation

void timer_pool_init void   
 

Author:
Date:
18.07.2001
Warning:
  • This function must be invoked at startup before any other timer function is used.
This function resets all timer counter to zero and initializes all timers to available (free) state.

Definition at line 105 of file timers.c.

References NUMTIMERS, timer_pool, and TRUE.

UINT8 get_timer void   
 

Author:
Date:
18.07.2001
Returns:
Handle to a free timer
Warning:
  • Timers are considered to be critical resources, so if there is no available timer and get_timer is invoked, system will reset.
Invoke this function to obtain a free timer (it's handle that is) from the timer pool.

Definition at line 131 of file timers.c.

References FALSE, NUMTIMERS, RESET_SYSTEM, timer_pool, and TRUE.

Referenced by arp_init(), bootpc_init(), dhcpc_init(), dns_init(), pop3c_init(), smtpc_init(), tcp_init(), and tftps_init().

void free_timer UINT8    nbr
 

Author:
Date:
18.07.2001
Parameters:
nbr  handle to timer beeing released
This function releases the timer who's handle is supplied as parameter. Use this when timer is not needed any more and other applications might use it.

Definition at line 169 of file timers.c.

References NUMTIMERS, timer_pool, and TRUE.

void init_timer UINT8    nbr,
UINT32    tout
 

Author:
Date:
18.07.2001
Parameters:
nbr  handle of timer who's value we're setting
tout  time-out value to set for this timer
Invoke this function to set timeout value for a timer with a given handle.

TIMERTIC defines how quickly the timers' values are decremented so is it to initialize timers to correct timeouts.

Definition at line 194 of file timers.c.

References NUMTIMERS, OS_EnterCritical, OS_ExitCritical, timer_pool, and TRUE.

Referenced by arp_init(), arp_manage(), bootpc_run(), dhcpc_init(), dhcpc_run(), dns_retransmit(), get_host_by_name(), tcp_init(), tcp_newstate(), and tcp_poll().

UINT32 check_timer UINT8    nbr
 

Author:
Date:
18.07.2001
Parameters:
nbr  timer handle who's value is to be returned
Returns:
timer value
Warning:
  • Interrupts are not disabled when fetching the value, therefore returned value possibly has an error component +/- TIMERTIC.
Function simply returns timer value of a given timer. No checks are made in order to make the function as fast as possible.

Definition at line 233 of file timers.c.

References timer_pool.

Referenced by arp_manage(), bootpc_run(), dhcpc_run(), dns_run(), and tcp_poll().

void decrement_timers void   
 

Author:
Date:
18.07.2001
Invoke this function from timer interrupt to decrement timer counter values

Definition at line 248 of file timers.c.

References FALSE, NUMTIMERS, and timer_pool.


Variable Documentation

struct { ... } timer_pool[NUMTIMERS]
 

This timer pool is extensively used by most of the modules of the OpenTCP project. All timers that are used are allocated from this pool. Maximum number of timers that can be used at any given time is defined by the NUMTIMERS define.

Referenced by check_timer(), decrement_timers(), free_timer(), get_timer(), init_timer(), and timer_pool_init().


Generated on Sun Aug 3 20:33:00 2003 for OpenTCP by doxygen1.2.18