ssm
Runtime Library for the Sparse Synchronous Model
Data Structures | Macros | Typedefs | Functions | Variables
ssm.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <assert.h>
#include <stddef.h>
#include "ssm-debug.h"
Include dependency graph for ssm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ssm_act
 Activation record for an SSM routine. More...
 
struct  ssm_trigger
 Indicates a routine should run when a scheduled variable is written. More...
 
struct  ssm_sv
 A variable that may have scheduled updates and triggers. More...
 
struct  ssm_bool_t
 Scheduled Boolean variable. More...
 
struct  ssm_i8_t
 Scheduled 8-bit Signed Integer variable. More...
 
struct  ssm_i16_t
 Scheduled 16-bit Signed Integer variable. More...
 
struct  ssm_i32_t
 Scheduled 32-bit Signed Integer variable. More...
 
struct  ssm_i64_t
 Scheduled 64-bit Signed Integer variable. More...
 
struct  ssm_u8_t
 Scheduled 8-bit Unsigned Integer variable. More...
 
struct  ssm_u16_t
 Scheduled 16-bit Unsigned Integer variable. More...
 
struct  ssm_u32_t
 Scheduled 32-bit Unsigned Integer variable. More...
 
struct  ssm_u64_t
 Scheduled 64-bit Unsigned Integer variable. More...
 

Macros

#define SSM_ACT_MALLOC(size)   malloc(size)
 Allocation function for activation records. More...
 
#define SSM_ACT_FREE(ptr, size)   free(ptr)
 Free function for activation records. More...
 
#define SSM_RESOURCES_EXHAUSTED(string)   exit(1)
 Invoked when limited resources are exhausted, e.g., unable to allocate memory, no more queue space. More...
 
#define SSM_SECOND   1000000000L
 Ticks in a second. More...
 
#define SSM_NANOSECOND   (SSM_SECOND/1000000000L)
 Ticks per nanosecond. More...
 
#define SSM_MICROSECOND   (SSM_SECOND/1000000L)
 Ticks per microsecond. More...
 
#define SSM_MILLISECOND   (SSM_SECOND/1000L)
 Ticks per millisecond. More...
 
#define SSM_MINUTE   (SSM_SECOND*60L)
 Ticks per minute. More...
 
#define SSM_HOUR   (SSM_SECOND*3600L)
 Ticks per hour. More...
 
#define SSM_NEVER   UINT64_MAX
 Time indicating something will never happen. More...
 
#define SSM_ROOT_PRIORITY   0
 The priority for the entry point of an SSM program. More...
 
#define SSM_ROOT_DEPTH   (sizeof(ssm_priority_t) * 8)
 The depth at the entry point of an SSM program. More...
 
#define SSM_ACT_FIELDS
 "Base class" fields for user-defined activation records More...
 
#define member_type(type, member)   const void
 Implementation of container_of that falls back to ISO C99 when GNU C is not available (from https://stackoverflow.com/a/10269925/10497710) More...
 
#define container_of(ptr, type, member)
 
#define ssm_later_event(var, then)   ssm_schedule((var), (then))
 
#define SSM_DECLARE_SV_SCALAR(payload_t)
 
#define SSM_DEFINE_SV_SCALAR(payload_t)
 

Typedefs

typedef uint64_t ssm_time_t
 Absolute time; never to overflow. More...
 
typedef uint32_t ssm_priority_t
 Thread priority. More...
 
typedef uint8_t ssm_depth_t
 Index of least significant bit in a group of priorities. More...
 
typedef void ssm_stepf_t(struct ssm_act *)
 The function that does an instant's work for a routine. More...
 
typedef struct ssm_act ssm_act_t
 Activation record for an SSM routine. More...
 
typedef struct ssm_trigger ssm_trigger_t
 Indicates a routine should run when a scheduled variable is written. More...
 
typedef struct ssm_sv ssm_sv_t
 A variable that may have scheduled updates and triggers. More...
 
typedef ssm_sv_t ssm_event_t
 
typedef int8_t i8
 8-bit Signed Integer More...
 
typedef int16_t i16
 16-bit Signed Integer More...
 
typedef int32_t i32
 32-bit Signed Integer More...
 
typedef int64_t i64
 64-bit Signed Integer More...
 
typedef uint8_t u8
 8-bit Unsigned Integer More...
 
typedef uint16_t u16
 16-bit Unsigned Integer More...
 
typedef uint32_t u32
 32-bit Unsigned Integer More...
 
typedef uint64_t u64
 64-bit Unsigned Integer More...
 

Functions

void ssm_sensitize (ssm_sv_t *, ssm_trigger_t *)
 Indicate writing to a variable should trigger a routine. More...
 
void ssm_desensitize (ssm_trigger_t *)
 Disable a sensitized routine. More...
 
void ssm_activate (ssm_act_t *)
 Schedule a routine to run in the current instant. More...
 
static void ssm_call (ssm_act_t *act)
 Execute a routine immediately. More...
 
static ssm_act_tssm_enter (size_t bytes, ssm_stepf_t *step, ssm_act_t *parent, ssm_priority_t priority, ssm_depth_t depth)
 Enter a routine. More...
 
static void ssm_leave (ssm_act_t *act, size_t bytes)
 Deallocate an activation record; return to caller if we were the last child. More...
 
bool ssm_event_on (ssm_sv_t *var)
 Return true if there is an event on the given variable in the current instant. More...
 
void ssm_initialize (ssm_sv_t *var, void(*update)(ssm_sv_t *))
 Initialize a scheduled variable. More...
 
void ssm_schedule (ssm_sv_t *var, ssm_time_t later)
 Schedule a future update to a variable. More...
 
void ssm_unschedule (ssm_sv_t *var)
 Unschedule any pending event on a variable. More...
 
void ssm_trigger (ssm_sv_t *var, ssm_priority_t priority)
 Activate routines triggered by a variable. More...
 
ssm_time_t ssm_next_event_time (void)
 Return the time of the next event in the queue or SSM_NEVER. More...
 
ssm_time_t ssm_now (void)
 Return the current model time. More...
 
void ssm_tick ()
 Run the system for the next scheduled instant. More...
 
void ssm_reset ()
 Reset the scheduler. More...
 
void ssm_assign_event (ssm_event_t *var, ssm_priority_t prio)
 
void ssm_initialize_event (ssm_event_t *)
 
void ssm_assign_bool (ssm_bool_t *sv, ssm_priority_t prio, const bool value)
 
void ssm_later_bool (ssm_bool_t *sv, ssm_time_t then, const bool value)
 
void ssm_initialize_bool (ssm_bool_t *v)
 
void ssm_assign_i8 (ssm_i8_t *sv, ssm_priority_t prio, const i8 value)
 
void ssm_later_i8 (ssm_i8_t *sv, ssm_time_t then, const i8 value)
 
void ssm_initialize_i8 (ssm_i8_t *v)
 
void ssm_assign_i16 (ssm_i16_t *sv, ssm_priority_t prio, const i16 value)
 
void ssm_later_i16 (ssm_i16_t *sv, ssm_time_t then, const i16 value)
 
void ssm_initialize_i16 (ssm_i16_t *v)
 
void ssm_assign_i32 (ssm_i32_t *sv, ssm_priority_t prio, const i32 value)
 
void ssm_later_i32 (ssm_i32_t *sv, ssm_time_t then, const i32 value)
 
void ssm_initialize_i32 (ssm_i32_t *v)
 
void ssm_assign_i64 (ssm_i64_t *sv, ssm_priority_t prio, const i64 value)
 
void ssm_later_i64 (ssm_i64_t *sv, ssm_time_t then, const i64 value)
 
void ssm_initialize_i64 (ssm_i64_t *v)
 
void ssm_assign_u8 (ssm_u8_t *sv, ssm_priority_t prio, const u8 value)
 
void ssm_later_u8 (ssm_u8_t *sv, ssm_time_t then, const u8 value)
 
void ssm_initialize_u8 (ssm_u8_t *v)
 
void ssm_assign_u16 (ssm_u16_t *sv, ssm_priority_t prio, const u16 value)
 
void ssm_later_u16 (ssm_u16_t *sv, ssm_time_t then, const u16 value)
 
void ssm_initialize_u16 (ssm_u16_t *v)
 
void ssm_assign_u32 (ssm_u32_t *sv, ssm_priority_t prio, const u32 value)
 
void ssm_later_u32 (ssm_u32_t *sv, ssm_time_t then, const u32 value)
 
void ssm_initialize_u32 (ssm_u32_t *v)
 
void ssm_assign_u64 (ssm_u64_t *sv, ssm_priority_t prio, const u64 value)
 
void ssm_later_u64 (ssm_u64_t *sv, ssm_time_t then, const u64 value)
 
void ssm_initialize_u64 (ssm_u64_t *v)
 

Variables

ssm_act_t ssm_top_parent
 An activation record for the parent of the topmost routine. More...