#include <Timer.hpp>
Inheritance diagram for Timer::

Public Methods | |
| Timer (ULONG nsec, ULONG sec=0) | |
| __inline void | start () |
| virtual void | timedRun (int signo)=0 |
Static Public Methods | |
| void | wrapper (int signo) |
Public Attributes | |
| const ULONG | Period_1_ms = 1000000L |
| const ULONG | Period_10_ms = 10000000L |
| const ULONG | Period_20_ms = 20000000L |
| const ULONG | Period_50_ms = 50000000L |
| const ULONG | Period_100_ms = 100000000L |
| const ULONG | Period_250_ms = 250000000L |
| const ULONG | Period_500_ms = 500000000L |
| const ULONG | Period_750_ms = 750000000L |
Protected Methods | |
| Timer (ULONG nsec=0, ULONG sec=0) | |
| virtual void | run () |
| __inline double | getSpent () |
| __inline double | getElapsed (_uint64 started) |
| __inline _uint64 | getCycles () |
| virtual void | tick (int signo)=0 |
| Timer (ULONG nsec=0, ULONG sec=0) | |
| virtual void | run () |
| __inline double | getSpent () |
| __inline double | getElapsed (_uint64 started) |
| __inline _uint64 | getCycles () |
| virtual void | tick (int signo)=0 |
Static Protected Methods | |
| void | wrapper (int signo) |
| void | wrapper (int signo) |
Static Protected Attributes | |
| Timer * | theTimer = NULL |
| Timer * | theTimer |
Private Attributes | |
| clockid_t | timerid |
| sigevent | event |
| itimerspec | t |
| sigevent | event |
| itimerspec | t |
| sigevent | event |
| itimerspec | t |
|
||||||||||||
|
Definition at line 18 of file Timer.cpp. 00019 {
00020 if ( theTimer != NULL ) {
00021 delete theTimer;
00022 }
00023
00024 theTimer = this;
00025
00026 memset( &event, 0, sizeof( event ) );
00027
00028 // sched_get_priority_max( SCHED_RR ) == 63
00029
00030 event.sigev_priority = fixprio( 63 ); // 25
00031
00032 event.sigev_notify = SIGEV_SIGNAL;
00033 event.sigev_signo = TimerSignal;
00034
00035 memset( &t, 0, sizeof( t ) );
00036
00037 t.it_value.tv_nsec = nsec;
00038 t.it_interval.tv_nsec = nsec;
00039
00040 t.it_value.tv_sec = sec;
00041 t.it_interval.tv_sec = sec;
00042
00043 // create the timer, binding it to the event
00044
00045 if ( timer_create( CLOCK_REALTIME, &event, &timerid ) == -1 )
00046 {
00047 MC_OnError( errno, Error, "while creating a timer." )
00048 }
00049
00050 struct sigaction act;
00051 sigset_t set;
00052
00053 sigemptyset( &set );
00054 sigaddset( &set, TimerSignal );
00055
00056 // Define a handler for TimerSignal
00057 act.sa_flags = 0;
00058 act.sa_mask = set;
00059 act.sa_handler = wrapper;
00060
00061 sigaction( TimerSignal, &act, NULL );
00062
00063
00064 #if defined( __QNXNTO__ )
00065 last_cycles = 0;
00066 current_cycles = 0;
00067 cpu_freq = SYSPAGE_ENTRY( qtime )->cycles_per_sec;
00068
00069 clkper.nsec = 999847;
00070 clkper.fract = 0;
00071
00072 ClockPeriod( CLOCK_REALTIME, &clkper, NULL, 0 ); // ~1 ms
00073 #endif
00074
00075 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
Definition at line 92 of file Timer.cpp. 00092 {
00093 return ClockCycles();
00094 }
|
|
|
|
|
|
Definition at line 96 of file Timer.cpp. 00097 {
00098
00099 // Put pulse validation here
00100 current_cycles = ClockCycles();
00101
00102 // Could get rid of timer by using more clever timer setup
00103 elapsedCycles = ( current_cycles - cycles ) / cpu_freq;
00104
00105 return elapsedCycles;
00106 }
|
|
|
|
|
|
|
|
|
Reimplemented from Basic_PThread. |
|
|
Reimplemented from Basic_PThread. |
|
|
Definition at line 78 of file Timer.cpp. 00078 {
00079 // Increase concurrency level to number of CPU + 3
00080
00081 #if (__sun) || (__SUN__)
00082
00083 thr_setconcurrency( sysconf(_SC_NPROCESSORS_ONLN) + 3 );
00084
00085 #endif
00086
00087 startedTime = time( NULL );
00088
00089 timer_settime( timerid, 0, &t, NULL );
00090 }
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 68 of file Timer.hpp. 00069 {
00070 assert( signo == TimerSignal );
00071 theTimer->tick( signo );
00072 }
|
|
|
Definition at line 36 of file Timer.hpp. 00037 {
00038 theTimer->timedRun( signo );
00039 }
|
|
|
Definition at line 68 of file Timer.hpp. 00069 {
00070 assert( signo == TimerSignal );
00071 theTimer->tick( signo );
00072 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001