1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/********************************************************************
* Description: timer.hh
* A TIMER object lets you wait on the expiration of a cyclic
* period, to the resolution of the system clock.
*
* Derived from a work by Fred Proctor & Will Shackleford
*
* Author:
* License: LGPL Version 2
* System: Linux
*
* Copyright (c) 2004 All rights reserved.
*
* Last change:
********************************************************************/
extern "C" extern "C"
;
/* prototype for user-defined timing function */
typedef int ;
/* Getting rid of this stuff which no one uses and makes porting more
difficult */
/* prototype for signal hander function */
typedef void ;
/* RCS_TIMER_USE_ITIMER */
/*
general-purpose timer, which can be used for waiting until a
synchronous time tick, slept on for any period at all, or to
obtain a time in system clock ticks from creation of the timer.
*/
/*
Programmers can create RCS_TIMER objects to synchronize to the system clock or to some other event(s).
To synchronize a cyclic process to the system clock:
Initialize the RCS_TIMER object with the cycle period.
Call RCS_TIMER::wait() at the end of each cycle.
The cycle period will be rounded up to the resolution of the system clock or
the most precise time measuring or sleeping function available for the given
platform. RCS_TIMER::wait() will wait the remainder of the cycle period since
the last call. The units for the cycle time are seconds.
*/
/*
To synchronize to some other event(s):
Create a function that takes a (void *) as an argument and returns an int.
Initialize the RCS_TIMER object with a cycle period used only for diagnostics,
the address of the function and a parameter for the function.
Use RCS_TIMER::wait().
The user's function should return 0 when the event to synchronize to occurs or -1
if an error occurs. The argument passed to the users function will be whatever was
passed as the third parameter to the constructor of the RCS_TIMER or NULL if no
third argument is given. This argument could be used by the synchronizing function
to know which timer is calling it if the synchronization function is called by more
than one timer. Nothing will force the function to return within the cycle period but
there are ways to check if the function took longer than the cycle period after it returns.
*/
;