1 | Clock Manager |
---|
2 | ############# |
---|
3 | |
---|
4 | Introduction |
---|
5 | ============ |
---|
6 | |
---|
7 | The clock manager provides services two primary classes |
---|
8 | of services. The first focuses on obtaining and setting |
---|
9 | the current date and time. The other category of services |
---|
10 | focus on allowing a thread to delay for a specific length |
---|
11 | of time. |
---|
12 | |
---|
13 | The directives provided by the clock manager are: |
---|
14 | |
---|
15 | - ``clock_gettime`` - Obtain Time of Day |
---|
16 | |
---|
17 | - ``clock_settime`` - Set Time of Day |
---|
18 | |
---|
19 | - ``clock_getres`` - Get Clock Resolution |
---|
20 | |
---|
21 | - ``sleep`` - Delay Process Execution |
---|
22 | |
---|
23 | - ``usleep`` - Delay Process Execution in Microseconds |
---|
24 | |
---|
25 | - ``nanosleep`` - Delay with High Resolution |
---|
26 | |
---|
27 | - ``gettimeofday`` - Get the Time of Day |
---|
28 | |
---|
29 | - ``time`` - Get time in seconds |
---|
30 | |
---|
31 | Background |
---|
32 | ========== |
---|
33 | |
---|
34 | There is currently no text in this section. |
---|
35 | |
---|
36 | Operations |
---|
37 | ========== |
---|
38 | |
---|
39 | There is currently no text in this section. |
---|
40 | |
---|
41 | Directives |
---|
42 | ========== |
---|
43 | |
---|
44 | This section details the clock manager's directives. |
---|
45 | A subsection is dedicated to each of this manager's directives |
---|
46 | and describes the calling sequence, related constants, usage, |
---|
47 | and status codes. |
---|
48 | |
---|
49 | clock_gettime - Obtain Time of Day |
---|
50 | ---------------------------------- |
---|
51 | .. index:: clock_gettime |
---|
52 | .. index:: obtain time of day |
---|
53 | |
---|
54 | **CALLING SEQUENCE:** |
---|
55 | |
---|
56 | .. code:: c |
---|
57 | |
---|
58 | #include <time.h> |
---|
59 | int clock_gettime( |
---|
60 | clockid_t clock_id, |
---|
61 | struct timespec \*tp |
---|
62 | ); |
---|
63 | |
---|
64 | **STATUS CODES:** |
---|
65 | |
---|
66 | On error, this routine returns -1 and sets errno to one of the following: |
---|
67 | |
---|
68 | *EINVAL* |
---|
69 | The tp pointer parameter is invalid. |
---|
70 | |
---|
71 | *EINVAL* |
---|
72 | The clock_id specified is invalid. |
---|
73 | |
---|
74 | **DESCRIPTION:** |
---|
75 | |
---|
76 | **NOTES:** |
---|
77 | |
---|
78 | NONE |
---|
79 | |
---|
80 | clock_settime - Set Time of Day |
---|
81 | ------------------------------- |
---|
82 | .. index:: clock_settime |
---|
83 | .. index:: set time of day |
---|
84 | |
---|
85 | **CALLING SEQUENCE:** |
---|
86 | |
---|
87 | .. code:: c |
---|
88 | |
---|
89 | #include <time.h> |
---|
90 | int clock_settime( |
---|
91 | clockid_t clock_id, |
---|
92 | const struct timespec \*tp |
---|
93 | ); |
---|
94 | |
---|
95 | **STATUS CODES:** |
---|
96 | |
---|
97 | On error, this routine returns -1 and sets errno to one of the following: |
---|
98 | |
---|
99 | *EINVAL* |
---|
100 | The tp pointer parameter is invalid. |
---|
101 | |
---|
102 | *EINVAL* |
---|
103 | The clock_id specified is invalid. |
---|
104 | |
---|
105 | *EINVAL* |
---|
106 | The contents of the tp structure are invalid. |
---|
107 | |
---|
108 | **DESCRIPTION:** |
---|
109 | |
---|
110 | **NOTES:** |
---|
111 | |
---|
112 | NONE |
---|
113 | |
---|
114 | clock_getres - Get Clock Resolution |
---|
115 | ----------------------------------- |
---|
116 | .. index:: clock_getres |
---|
117 | .. index:: get clock resolution |
---|
118 | |
---|
119 | **CALLING SEQUENCE:** |
---|
120 | |
---|
121 | .. code:: c |
---|
122 | |
---|
123 | #include <time.h> |
---|
124 | int clock_getres( |
---|
125 | clockid_t clock_id, |
---|
126 | struct timespec \*res |
---|
127 | ); |
---|
128 | |
---|
129 | **STATUS CODES:** |
---|
130 | |
---|
131 | On error, this routine returns -1 and sets errno to one of the following: |
---|
132 | |
---|
133 | *EINVAL* |
---|
134 | The res pointer parameter is invalid. |
---|
135 | |
---|
136 | *EINVAL* |
---|
137 | The clock_id specified is invalid. |
---|
138 | |
---|
139 | **DESCRIPTION:** |
---|
140 | |
---|
141 | **NOTES:** |
---|
142 | |
---|
143 | If res is NULL, then the resolution is not returned. |
---|
144 | |
---|
145 | sleep - Delay Process Execution |
---|
146 | ------------------------------- |
---|
147 | .. index:: sleep |
---|
148 | .. index:: delay process execution |
---|
149 | |
---|
150 | **CALLING SEQUENCE:** |
---|
151 | |
---|
152 | .. code:: c |
---|
153 | |
---|
154 | #include <unistd.h> |
---|
155 | unsigned int sleep( |
---|
156 | unsigned int seconds |
---|
157 | ); |
---|
158 | |
---|
159 | **STATUS CODES:** |
---|
160 | |
---|
161 | This routine returns the number of unslept seconds. |
---|
162 | |
---|
163 | **DESCRIPTION:** |
---|
164 | |
---|
165 | The ``sleep()`` function delays the calling thread by the specified |
---|
166 | number of ``seconds``. |
---|
167 | |
---|
168 | **NOTES:** |
---|
169 | |
---|
170 | This call is interruptible by a signal. |
---|
171 | |
---|
172 | usleep - Delay Process Execution in Microseconds |
---|
173 | ------------------------------------------------ |
---|
174 | .. index:: usleep |
---|
175 | .. index:: delay process execution |
---|
176 | .. index:: delay process execution |
---|
177 | .. index:: usecs delay process execution |
---|
178 | .. index:: microsecond delay process execution |
---|
179 | |
---|
180 | **CALLING SEQUENCE:** |
---|
181 | |
---|
182 | .. code:: c |
---|
183 | |
---|
184 | #include <time.h> |
---|
185 | useconds_t usleep( |
---|
186 | useconds_t useconds |
---|
187 | ); |
---|
188 | |
---|
189 | **STATUS CODES:** |
---|
190 | |
---|
191 | This routine returns the number of unslept seconds. |
---|
192 | |
---|
193 | **DESCRIPTION:** |
---|
194 | |
---|
195 | The ``sleep()`` function delays the calling thread by the specified |
---|
196 | number of ``seconds``. |
---|
197 | |
---|
198 | The ``usleep()`` function suspends the calling thread from execution |
---|
199 | until either the number of microseconds specified by the``useconds`` argument has elapsed or a signal is delivered to the |
---|
200 | calling thread and its action is to invoke a signal-catching function |
---|
201 | or to terminate the process. |
---|
202 | |
---|
203 | Because of other activity, or because of the time spent in |
---|
204 | processing the call, the actual length of time the thread is |
---|
205 | blocked may be longer than |
---|
206 | the amount of time specified. |
---|
207 | |
---|
208 | **NOTES:** |
---|
209 | |
---|
210 | This call is interruptible by a signal. |
---|
211 | |
---|
212 | The Single UNIX Specification allows this service to be implemented using |
---|
213 | the same timer as that used by the ``alarm()`` service. This is*NOT* the case for *RTEMS* and this call has no interaction with |
---|
214 | the ``SIGALRM`` signal. |
---|
215 | |
---|
216 | nanosleep - Delay with High Resolution |
---|
217 | -------------------------------------- |
---|
218 | .. index:: nanosleep |
---|
219 | .. index:: delay with high resolution |
---|
220 | |
---|
221 | **CALLING SEQUENCE:** |
---|
222 | |
---|
223 | .. code:: c |
---|
224 | |
---|
225 | #include <time.h> |
---|
226 | int nanosleep( |
---|
227 | const struct timespec \*rqtp, |
---|
228 | struct timespec \*rmtp |
---|
229 | ); |
---|
230 | |
---|
231 | **STATUS CODES:** |
---|
232 | |
---|
233 | On error, this routine returns -1 and sets errno to one of the following: |
---|
234 | |
---|
235 | *EINTR* |
---|
236 | The routine was interrupted by a signal. |
---|
237 | |
---|
238 | *EAGAIN* |
---|
239 | The requested sleep period specified negative seconds or nanoseconds. |
---|
240 | |
---|
241 | *EINVAL* |
---|
242 | The requested sleep period specified an invalid number for the nanoseconds |
---|
243 | field. |
---|
244 | |
---|
245 | **DESCRIPTION:** |
---|
246 | |
---|
247 | **NOTES:** |
---|
248 | |
---|
249 | This call is interruptible by a signal. |
---|
250 | |
---|
251 | gettimeofday - Get the Time of Day |
---|
252 | ---------------------------------- |
---|
253 | .. index:: gettimeofday |
---|
254 | .. index:: get the time of day |
---|
255 | |
---|
256 | **CALLING SEQUENCE:** |
---|
257 | |
---|
258 | .. code:: c |
---|
259 | |
---|
260 | #include <sys/time.h> |
---|
261 | #include <unistd.h> |
---|
262 | int gettimeofday( |
---|
263 | struct timeval \*tp, |
---|
264 | struct timezone \*tzp |
---|
265 | ); |
---|
266 | |
---|
267 | **STATUS CODES:** |
---|
268 | |
---|
269 | On error, this routine returns -1 and sets ``errno`` as appropriate. |
---|
270 | |
---|
271 | *EPERM* |
---|
272 | ``settimeofdat`` is called by someone other than the superuser. |
---|
273 | |
---|
274 | *EINVAL* |
---|
275 | Timezone (or something else) is invalid. |
---|
276 | |
---|
277 | *EFAULT* |
---|
278 | One of ``tv`` or ``tz`` pointed outside your accessible address |
---|
279 | space |
---|
280 | |
---|
281 | **DESCRIPTION:** |
---|
282 | |
---|
283 | This routine returns the current time of day in the ``tp`` structure. |
---|
284 | |
---|
285 | **NOTES:** |
---|
286 | |
---|
287 | Currently, the timezone information is not supported. The ``tzp`` |
---|
288 | argument is ignored. |
---|
289 | |
---|
290 | time - Get time in seconds |
---|
291 | -------------------------- |
---|
292 | .. index:: time |
---|
293 | .. index:: get time in seconds |
---|
294 | |
---|
295 | **CALLING SEQUENCE:** |
---|
296 | |
---|
297 | .. code:: c |
---|
298 | |
---|
299 | #include <time.h> |
---|
300 | int time( |
---|
301 | time_t \*tloc |
---|
302 | ); |
---|
303 | |
---|
304 | **STATUS CODES:** |
---|
305 | |
---|
306 | This routine returns the number of seconds since the Epoch. |
---|
307 | |
---|
308 | **DESCRIPTION:** |
---|
309 | |
---|
310 | ``time`` returns the time since 00:00:00 GMT, January 1, 1970, |
---|
311 | measured in seconds |
---|
312 | |
---|
313 | If ``tloc`` in non null, the return value is also stored in the |
---|
314 | memory pointed to by ``t``. |
---|
315 | |
---|
316 | **NOTES:** |
---|
317 | |
---|
318 | NONE |
---|
319 | |
---|
320 | .. COMMENT: This is the chapter from the RTEMS POSIX 1003.1b API User's Guide that |
---|
321 | |
---|
322 | .. COMMENT: documents the services provided by the timer @c manager. |
---|
323 | |
---|