Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

timing.c File Reference

Go to the source code of this file.

Functions

int start_chrono ()
 Start the stopwatch.

int stop_chrono ()
 Stop the stopwatch.

unsigned long int get_ms ()
 Get the measured time in ms.

int set_one_shot_timer (long sec, long micro_second)
 Create a one shot timer which precision is the micro second. The timer raises the signal SIGALRM when the timout expired.

int cancel_one_shot_timer ()
 Cancel the previously activated one shot timer.

int pause_one_shot_timer ()
 Pause the one shot timer.

int restart_one_shot_timer ()
 Restart the one shot timer.


Variables

timeval start
 Static variable used by start_chrono() to save the starting timestamp.

timeval stop
 Static variable used by stop_chrono() to save the stoping timestamp.

itimerval one_shot_timer
 This structure is used to specify the timer's delay (for a one shot timer).

itimerval old_one_shot_timer
 This variable is used by the system call setitimer(). This system call requires a structure itimerval to save the current timer configuration (it is not used here).

itimerval current_one_shot_timer
 This variable is used by the functions pause_one_shot_timer() and restart_one_shot_timer(). It is used to save the current timer's state (i.e: the remaining time).


Detailed Description

This file contains functions for time management.

Definition in file timing.c.


Function Documentation

int cancel_one_shot_timer  
 

Cancel the previously activated one shot timer.

Returns:
The function returns one of the following values:
  • CANCEL_ONE_SHOT_TIMER_ERROR: An error occured while canceling the timer.
  • CANCEL_ONE_SHOT_TIMER_OK: The timer is successfuly canceled.
Examples:
test_one_shot_timer.c.

Definition at line 99 of file timing.c.

References CANCEL_ONE_SHOT_TIMER_ERROR, CANCEL_ONE_SHOT_TIMER_OK, old_one_shot_timer, and one_shot_timer.

Referenced by pause_one_shot_timer().

unsigned long int get_ms  
 

Get the measured time in ms.

Returns:
The function returns the number of mili seceond.
Examples:
test_one_shot_timer.c, and test_stopwatch.c.

Definition at line 36 of file timing.c.

References start, and stop.

int pause_one_shot_timer  
 

Pause the one shot timer.

Returns:
The function return one of the following values:
  • PAUSE_ONE_SHOT_TIMER_ERROR: An error occured with the high precision timer.
  • PAUSE_ONE_SHOT_TIMER_OK: The operation was successful.
Warning:
You can restart the timer with restart_one_shot_timer().
Examples:
test_one_shot_timer.c.

Definition at line 124 of file timing.c.

References cancel_one_shot_timer(), CANCEL_ONE_SHOT_TIMER_OK, current_one_shot_timer, PAUSE_ONE_SHOT_TIMER_ERROR, and PAUSE_ONE_SHOT_TIMER_OK.

int restart_one_shot_timer  
 

Restart the one shot timer.

Returns:
The function return one of the following values:
  • RESTART_ONE_SHOT_TIMER_ERROR: An error occured with the high precision timer.
  • RESTART_ONE_SHOT_TIMER_OK: The operation was successful.
Warning:
The timer should have been paused with the function pause_one_shot_timer().
Examples:
test_one_shot_timer.c.

Definition at line 148 of file timing.c.

References current_one_shot_timer, old_one_shot_timer, RESTART_ONE_SHOT_TIMER_ERROR, and RESTART_ONE_SHOT_TIMER_OK.

int set_one_shot_timer long    sec,
long    micro_second
 

Create a one shot timer which precision is the micro second. The timer raises the signal SIGALRM when the timout expired.

Parameters:
sec Number of second
micro_second Number of micro seconds.
Returns:
The function returns one of the following values:
  • SET_ONE_SHOT_TIMER_ERROR: An error occured while creating the timer.
  • SET_ONE_SHOT_TIMER_OK: The timer is successfuly created.
Examples:
test_one_shot_timer.c.

Definition at line 75 of file timing.c.

References old_one_shot_timer, one_shot_timer, SET_ONE_SHOT_TIMER_ERROR, and SET_ONE_SHOT_TIMER_OK.

int start_chrono  
 

Start the stopwatch.

Returns:
Upon successful completion, the function returns 0. Otherwise the function returns -1;
Examples:
test_one_shot_timer.c, and test_stopwatch.c.

Definition at line 18 of file timing.c.

References start.

int stop_chrono  
 

Stop the stopwatch.

Returns:
Upon successful completion, the function returns 0. Otherwise the function returns -1;
Examples:
test_one_shot_timer.c, and test_stopwatch.c.

Definition at line 27 of file timing.c.

References stop.


Generated on Thu Apr 3 16:23:47 2003 for Common_C_libraries by doxygen1.3-rc1