The CLOCK_REALTIME clock measures the amount of time that has elapsed since 00:00:00 January 1, 1970 Greenwich Mean Time (GMT).
Clock Functions are below
Function | Description |
clock_getres | Returns the resolution of the specified clock |
clock_gettime | Returns the current value for the specified clock |
clock_settime | Sets the specified clock to the specified value |
#include#include
The
typedef struct timespectimespec
data structure consists of two members, tv_sec and tv_nsec, and takes the following form:{ time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
} timespec_t;
struct itimerspec {
struct timespec it_interval; /* Timer interval */
struct timespec it_value; /* Initial expiration */
};
Member | Zero | Non-Zero |
it_value | No expiration value Disarm the timer | Expiration value Arm the timer |
it_interval | No reload value Use as a one-shot timer | Interval reload value Use as a periodic timer |
specify a timer that executes only once, 5.25 seconds from now
mytimer.it_value.tv_sec = 5;
mytimer.it_value.tv_nsec = 250000000;
mytimer.it_interval.tv_sec = 0;
mytimer.it_interval.tv_nsec = 0;
timer to execute 15 seconds from now and then at 0.5 second intervals
mytimer.it_value.tv_sec = 15;
mytimer.it_value.tv_nsec = 0;
mytimer.it_interval.tv_sec = 0;
mytimer.it_interval.tv_nsec = 500000000;
Timer Functions are below.
Function | Description |
timer_create | Returns a unique timer ID used in subsequent calls to identify a timer based on the systemwide clock |
timer_delete | Removes a previously allocated, specified timer |
timer_getoverrun | Returns the timer expiration overrun count for the specified timer |
timer_gettime | Returns the amount of time before the specified timer is due to expire and the repetition value |
timer_settime | Sets the value of the specified timer either to an offset from the current clock setting or to an absolute value |
No comments:
Post a Comment