source: rtems-docs/posix_users/clock.rst @ ed3794e

4.115
Last change on this file since ed3794e was d389819, checked in by Amar Takhar <amar@…>, on 01/18/16 at 05:37:40

Convert all Unicode to ASCII(128)

  • Property mode set to 100644
File size: 6.4 KB
Line 
1Clock Manager
2#############
3
4Introduction
5============
6
7The clock manager provides services two primary classes
8of services.  The first focuses on obtaining and setting
9the current date and time.  The other category of services
10focus on allowing a thread to delay for a specific length
11of time.
12
13The 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
31Background
32==========
33
34There is currently no text in this section.
35
36Operations
37==========
38
39There is currently no text in this section.
40
41Directives
42==========
43
44This section details the clock manager's directives.
45A subsection is dedicated to each of this manager's directives
46and describes the calling sequence, related constants, usage,
47and status codes.
48
49clock_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
66On 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
78NONE
79
80clock_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
97On 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
112NONE
113
114clock_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
131On 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
143If res is NULL, then the resolution is not returned.
144
145sleep - 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
161This routine returns the number of unslept seconds.
162
163**DESCRIPTION:**
164
165The ``sleep()`` function delays the calling thread by the specified
166number of ``seconds``.
167
168**NOTES:**
169
170This call is interruptible by a signal.
171
172usleep - 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
191This routine returns the number of unslept seconds.
192
193**DESCRIPTION:**
194
195The ``sleep()`` function delays the calling thread by the specified
196number of ``seconds``.
197
198The ``usleep()`` function suspends the calling thread from execution
199until either the number of microseconds specified by the``useconds`` argument has elapsed or a signal is delivered to the
200calling thread and its action is to invoke a signal-catching function
201or to terminate the process.
202
203Because of other activity, or because of the time spent in
204processing the call, the actual length of time the thread is
205blocked may be longer than
206the amount of time specified.
207
208**NOTES:**
209
210This call is interruptible by a signal.
211
212The Single UNIX Specification allows this service to be implemented using
213the same timer as that used by the ``alarm()`` service.  This is*NOT* the case for *RTEMS* and this call has no interaction with
214the ``SIGALRM`` signal.
215
216nanosleep - 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
233On 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
249This call is interruptible by a signal.
250
251gettimeofday - 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
269On 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
283This routine returns the current time of day in the ``tp`` structure.
284
285**NOTES:**
286
287Currently, the timezone information is not supported. The ``tzp``
288argument is ignored.
289
290time - 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
306This 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,
311measured in seconds
312
313If ``tloc`` in non null, the return value is also stored in the
314memory pointed to by ``t``.
315
316**NOTES:**
317
318NONE
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
Note: See TracBrowser for help on using the repository browser.