Time-related functions.
More...
Go to the source code of this file.
|
#define | ITIMER_REAL 0 |
| This timer counts down in real (i.e., wall clock) time. At each expiration, a SIGALRM signal is generated.
|
|
#define | ITIMER_VIRTUAL 1 |
| This timer counts down against the user-mode CPU time consumed by the process. At each expiration, a SIGVTALRM signal is generated.
|
|
#define | ITIMER_PROF 2 |
| This timer counts down against the total (i.e., both user and system) CPU time consumed by the process. At each expiration, a SIGPROF signal is generated.
|
|
|
typedef unsigned int | time_t |
| Used to store time values.
|
|
typedef struct tm | tm_t |
| Used to get information about the current time.
|
|
typedef struct timeval | timeval_t |
| Rappresents time.
|
|
typedef struct itimerval | itimerval_t |
| Rappresents a time interval.
|
|
typedef struct timespec | timespec_t |
| Specify intervals of time with nanosecond precision.
|
|
|
time_t | time (time_t *t) |
| Returns the current time. More...
|
|
time_t | difftime (time_t time1, time_t time2) |
| Return the difference between the two time values. More...
|
|
tm_t * | localtime (const time_t *timep) |
| The current time broken down into a tm_t structure. More...
|
|
size_t | strftime (char *s, size_t max, const char *format, const tm_t *tm) |
| Formats the time tm according to the format specification format and places the result in the character array s of size max. More...
|
|
int | nanosleep (const struct timespec *req, struct timespec *rem) |
| Suspends the execution of the calling thread. More...
|
|
unsigned int | sleep (unsigned int seconds) |
| Causes the calling thread to sleep either until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored. More...
|
|
int | getitimer (int which, struct itimerval *curr_value) |
| Fills the structure pointed to by curr_value with the current setting for the timer specified by which. More...
|
|
int | setitimer (int which, const struct itimerval *new_value, struct itimerval *old_value) |
| The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts. More...
|
|
Time-related functions.
- Copyright
- (c) 2014-2024 This file is distributed under the MIT License. See LICENSE.md for details.
◆ difftime()
Return the difference between the two time values.
- Parameters
-
time1 | The first time value. |
time2 | The second time value. |
- Returns
- The difference in terms of seconds.
◆ getitimer()
int getitimer |
( |
int |
which, |
|
|
struct itimerval * |
curr_value |
|
) |
| |
Fills the structure pointed to by curr_value with the current setting for the timer specified by which.
- Parameters
-
which | which timer. |
curr_value | where we place the timer value. |
- Returns
- 0 on success, -1 on failure and errno is set to indicate the error.
◆ localtime()
The current time broken down into a tm_t structure.
- Parameters
-
timep | A pointer to a variable holding the current time. |
- Returns
- The time broken down.
◆ nanosleep()
Suspends the execution of the calling thread.
- Parameters
-
req | The amount of time we want to sleep. |
rem | The remaining time we did not sleep. |
- Returns
- If the call is interrupted by a signal handler, nanosleep() returns -1, sets errno to EINTR, and writes the remaining time into the structure pointed to by rem unless rem is NULL.
The execution is suspended until either at least the time specified in *req has elapsed, or the delivery of a signal that triggers the invocation of a handler in the calling thread or that terminates the process.
◆ setitimer()
int setitimer |
( |
int |
which, |
|
|
const struct itimerval * |
new_value, |
|
|
struct itimerval * |
old_value |
|
) |
| |
The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.
- Parameters
-
which | which timer. |
new_value | the new value for the timer. |
old_value | output variable where the function places the previous value. |
- Returns
- 0 on success, -1 on failure and errno is set to indicate the error.
◆ sleep()
unsigned int sleep |
( |
unsigned int |
seconds | ) |
|
Causes the calling thread to sleep either until the number of real-time seconds specified in seconds have elapsed or until a signal arrives which is not ignored.
- Parameters
-
seconds | The number of seconds we want to sleep. |
- Returns
- Zero if the requested time has elapsed, or the number of seconds left to sleep, if the call was interrupted by a signal handler.
◆ strftime()
Formats the time tm according to the format specification format and places the result in the character array s of size max.
- Parameters
-
s | The destination buffer. |
max | The maximum length of the buffer. |
format | The buffer used to generate the time. |
tm | The broken-down time. |
- Returns
- The number of bytes (excluding the terminating null) placed in s.
◆ time()
Returns the current time.
- Parameters
-
t | Where the time should be stored. |
- Returns
- The current time.