M0 time delivers resolution in nanoseconds. It is an unsigned 64-bit integer.
Implementation of m0_time_t on top of kernel struct timespec
Implementation of time functions on top of all m0_time_t defs
Time functions can use different clock sources.
- See also
- M0_CLOCK_SOURCE
◆ M0_MKTIME
Similar to m0_time(). To be used in initialisers.
Definition at line 86 of file time.h.
◆ TIME_F
◆ TIME_P
◆ m0_time_t
◆ anonymous enum
Enumerator |
---|
M0_TIME_ONE_SECOND | |
M0_TIME_ONE_MSEC | |
Definition at line 39 of file time.h.
◆ m0_clock_gettime_wrapper()
◆ m0_clock_gettimeofday_wrapper()
M0_INTERNAL m0_time_t m0_clock_gettimeofday_wrapper |
( |
void |
| ) |
|
◆ m0_nanosleep()
Sleep for requested time
Sleep for requested time. If interrupted, remaining time returned.
- Parameters
-
req | requested time to sleep |
rem | [OUT] remaining time, NULL causes remaining time to be ignored. |
- Returns
- 0 means success. -1 means error. Remaining time is stored in rem.
Definition at line 73 of file ktime.c.
◆ m0_time()
Create and return a m0_time_t from seconds and nanoseconds.
Definition at line 41 of file time.c.
◆ m0_time_add()
Add t2 to t1 and return that result.
- Returns
- The result time. If either t1 or t2 is M0_TIME_NEVER, the result is M0_TIME_NEVER.
Definition at line 47 of file time.c.
◆ m0_time_fini()
M0_INTERNAL void m0_time_fini |
( |
void |
| ) |
|
◆ m0_time_from_now()
m0_time_t m0_time_from_now |
( |
uint64_t |
secs, |
|
|
long |
ns |
|
) |
| |
Create a m0_time_t initialised with seconds + nanosecond in the future.
- Parameters
-
secs | seconds from now |
ns | nanoseconds from now |
- Returns
- The result time.
Definition at line 96 of file time.c.
◆ m0_time_init()
M0_INTERNAL int m0_time_init |
( |
void |
| ) |
|
◆ m0_time_is_in_past()
◆ m0_time_nanoseconds()
uint64_t m0_time_nanoseconds |
( |
const m0_time_t |
time | ) |
|
Get "nanosecond" part from the time.
Definition at line 89 of file time.c.
◆ m0_time_now()
Get the current time. This may or may not relate to wall time.
Definition at line 134 of file time.c.
◆ m0_time_seconds()
uint64_t m0_time_seconds |
( |
const m0_time_t |
time | ) |
|
Get "second" part from the time.
Definition at line 83 of file time.c.
◆ m0_time_sub()
Subtract t2 from t1 and return that result.
- Returns
- The result time. If t1 == M0_TIME_NEVER, M0_TIME_NEVER is returned.
- Precondition
- t2 < M0_TIME_NEVER && t1 >= t2
Definition at line 65 of file time.c.
◆ m0_time_to_realtime()
Useful for mutex/semaphore implementation. This function will translate time from value obtained from m0_time_now() to value that can be used with CLOCK_REALTIME-only functions such as sem_timedwait() and pthread_mutex_timedlock().
- Parameters
-
time | Time obtained from m0_time_now() and adjusted somehow if needed. |
- Returns
- Converted time value.
- Note
- In some cases this function will have 2 calls to clock_gettime().
Definition at line 160 of file time.c.
◆ M0_CLOCK_SOURCE [1/2]
◆ M0_CLOCK_SOURCE [2/2]
◆ M0_TIME_IMMEDIATELY [1/2]
Special value of abs_timeout indicates that action should be performed immediately
Definition at line 107 of file time.c.
◆ M0_TIME_IMMEDIATELY [2/2]
Special value of abs_timeout indicates that action should be performed immediately
Definition at line 107 of file time.c.
◆ m0_time_monotonic_offset [1/2]
Offset for M0_CLOCK_SOURCE_REALTIME_MONOTONIC clock source.
- See also
- m0_utime_init()
Definition at line 113 of file time.c.
◆ m0_time_monotonic_offset [2/2]
Offset for M0_CLOCK_SOURCE_REALTIME_MONOTONIC clock source.
- See also
- m0_utime_init()
Definition at line 113 of file time.c.
◆ M0_TIME_NEVER [1/2]
The largest time that is never reached in system life.
Definition at line 108 of file time.c.
◆ M0_TIME_NEVER [2/2]
The largest time that is never reached in system life.
Definition at line 108 of file time.c.