ssm
0.0.2
Runtime Library for the Sparse Synchronous Model
|
SSM timestamps are 64-bit values which should never wraparound, and are represented by ssm_time_t. More...
SSM timestamps are 64-bit values which should never wraparound, and are represented by ssm_time_t.
The runtime library maintains a monotonically increasing "current time" which can be read using ssm_now().
For portability reasons, this particular runtime implementation uses nanoseconds as its time base; it is the responsibility of platform code to convert this resolution to the tick rate of the hardware timer. See https://github.com/ssm-lang/ssm-runtime/pull/1.
Data Structures | |
struct | ssm_time |
Heap-allocated time values. More... | |
Macros | |
#define | SSM_NEVER UINT64_MAX |
Time indicating something will never happen. More... | |
#define | SSM_NANOSECOND 1L |
Ticks per nanosecond. More... | |
#define | SSM_MICROSECOND (SSM_NANOSECOND * 1000L) |
Ticks per microsecond. More... | |
#define | SSM_MILLISECOND (SSM_MICROSECOND * 1000L) |
Ticks per millisecond. More... | |
#define | SSM_SECOND (SSM_MILLISECOND * 1000L) |
Ticks per second. More... | |
#define | SSM_MINUTE (SSM_SECOND * 60L) |
Ticks per minute. More... | |
#define | SSM_HOUR (SSM_MINUTE * 60L) |
Ticks per hour. More... | |
#define | ssm_new_time(t) |
#define | ssm_time_read(v) (container_of((v).heap_ptr, struct ssm_time, mm)->time) |
Read the heap-allocated time pointed to by an ssm_value_t. More... | |
Typedefs | |
typedef uint64_t | ssm_time_t |
Absolute time; never to overflow. More... | |
Functions | |
ssm_time_t | ssm_next_event_time (void) |
The time of the next event in the event queue. More... | |
void | ssm_reset (void) |
Reset the scheduler. More... | |
void | ssm_set_now (ssm_time_t next) |
Advance the current model time. More... | |
ssm_time_t | ssm_now (void) |
The current model time. More... | |
ssm_value_t | ssm_new_time_int (ssm_time_t time) |
Allocate a ssm_time on the heap. More... | |
#define SSM_NEVER UINT64_MAX |
Time indicating something will never happen.
The value of this must be derived from the underlying type of ssm_time_t.
#define SSM_MICROSECOND (SSM_NANOSECOND * 1000L) |
#define SSM_MILLISECOND (SSM_MICROSECOND * 1000L) |
#define SSM_SECOND (SSM_MILLISECOND * 1000L) |
#define SSM_MINUTE (SSM_SECOND * 60L) |
#define SSM_HOUR (SSM_MINUTE * 60L) |
#define ssm_new_time | ( | t | ) |
#define ssm_time_read | ( | v | ) | (container_of((v).heap_ptr, struct ssm_time, mm)->time) |
Read the heap-allocated time pointed to by an ssm_value_t.
v | the ssm_value_t |
typedef uint64_t ssm_time_t |
ssm_time_t ssm_next_event_time | ( | void | ) |
The time of the next event in the event queue.
Used to determine whether and when to invoke ssm_tick().
Definition at line 391 of file ssm-scheduler.c.
void ssm_reset | ( | void | ) |
Reset the scheduler.
Set now to 0; clear the event and activation record queues.
This does not need to be called before calling ssm_tick() for the first time; the global state automatically starts initialized.
Definition at line 395 of file ssm-scheduler.c.
void ssm_set_now | ( | ssm_time_t | next | ) |
Advance the current model time.
next must be later than ssm_now(), and earlier than or equal to ssm_next_event_time().
Exposed so that platform code can perform external variable updates, to implement external inputs.
next | the time to advance to. |
SSM_INVALID_TIME | next is earlier than or equal to now. |
SSM_NOT_READY | next is later than the earliest queued event. |
Definition at line 401 of file ssm-scheduler.c.
ssm_time_t ssm_now | ( | void | ) |
The current model time.
Definition at line 267 of file ssm-scheduler.c.
ssm_value_t ssm_new_time_int | ( | ssm_time_t | time | ) |
Allocate a ssm_time on the heap.
time | what the heap-allocated time field is initialized to. |