reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
clock.c File Reference

Implementations of functions in clock.h. More...

#include "clock.h"
#include "low_level_platform.h"

Functions

void clock_sync_add_offset (instant_t *t)
 Add the current clock synchronization offset to a specified timestamp.
 
void clock_sync_subtract_offset (instant_t *t)
 Subtract the clock synchronization offset from a timestamp.
 
int lf_clock_gettime (instant_t *now)
 
int lf_clock_interruptable_sleep_until_locked (environment_t *env, instant_t wakeup_time)
 
int lf_clock_cond_timedwait (lf_cond_t *cond, instant_t wakeup_time)
 

Detailed Description

Implementations of functions in clock.h.

Author
Erling Jellum

Function Documentation

◆ clock_sync_add_offset()

void clock_sync_add_offset ( instant_t * t)

Add the current clock synchronization offset to a specified timestamp.

Parameters
tPointer to the timestamp to which to add the offset.

◆ clock_sync_subtract_offset()

void clock_sync_subtract_offset ( instant_t * t)

Subtract the clock synchronization offset from a timestamp.

Parameters
tThe timestamp from which to subtract the current clock sync offset.

◆ lf_clock_cond_timedwait()

int lf_clock_cond_timedwait ( lf_cond_t * cond,
instant_t wakeup_time )

Block the calling thread on the condition variable until it is signaled or until wakeup_time is reached. Before calling the appropriate function in the platform API, the wakeup_time will be translated into the correct timescale by removing any clock synchronization offset.

Returns
0 on success, LF_TIMEOUT on timeout, platform-specific error otherwise.

◆ lf_clock_gettime()

int lf_clock_gettime ( instant_t * now)

Retrieve the current physical time from the platform API. This adds any clock synchronization offset and guarantees monotonicity. Specifically, each returned value will be at least one nanosecond larger than any previously returned time.

Parameters
nowA pointer to the location in which to store the result.
Returns
0 on success, -1 on failure to read the platform clock.

◆ lf_clock_interruptable_sleep_until_locked()

int lf_clock_interruptable_sleep_until_locked ( environment_t * env,
instant_t wakeup_time )

Block the calling thread until wakeup_time is reached or the thread is interrupted by an asynchronous scheduling. This is used by the single-threaded runtime. Before calling the appropriate function in the platform API, the wakeup_time will be translated into the correct timescale by removing any clock synchronization offset.

Returns
0 on success or -1 if interrupted.