23 #define SSM_ASSERT(cond) \
26 SSM_THROW(SSM_INTERNAL_ERROR); \
159 void *(*alloc_mem_handler)(
size_t),
160 void (*free_mem_handler)(
void *,
size_t));
178 #ifndef SSM_MEM_POOL_MIN
185 #define SSM_MEM_POOL_MIN 16
188 #if SSM_MEM_POOL_MIN < SSM_POINTER_SIZE
189 #error SSM_MEM_POOL_MIN must be larger than word size.
192 #ifndef SSM_MEM_POOL_FACTOR_BASE2
199 #define SSM_MEM_POOL_FACTOR_BASE2 2
202 #if SSM_MEM_POOL_FACTOR_BASE2 < 1
203 #error SSM_MEM_POOL_FACTOR_BASE2 must be strictly greater than 0.
206 #ifndef SSM_MEM_POOL_COUNT
213 #define SSM_MEM_POOL_COUNT 4
216 #if SSM_MEM_POOL_COUNT < 1
217 #error SSM_MEM_POOL_COUNT must be strictly greater than 0.
227 #define SSM_MEM_POOL_SIZE(pool) \
228 (SSM_MEM_POOL_MIN << (SSM_MEM_POOL_FACTOR_BASE2 * pool))
234 #define SSM_MEM_POOL_MAX SSM_MEM_POOL_SIZE(SSM_MEM_POOL_COUNT - 1)
236 #ifndef SSM_MEM_PAGE_SIZE
241 #define SSM_MEM_PAGE_SIZE SSM_MEM_POOL_SIZE(SSM_MEM_POOL_COUNT)
244 #ifdef CONFIG_MEM_STATS
287 #include <valgrind/memcheck.h>
void ssm_tick(void)
Run the system for the next scheduled instant.
bool ssm_active(void)
Whether there are still active processes in the activation queue.
struct ssm_mem_statistics ssm_mem_statistics_t
Statistics for the heap; filled with ssm_mem_statistics_collect().
void ssm_mem_destroy(void(*free_page_handler)(void *))
Tears down the underlying allocator system.
struct ssm_mem_statistics_pool ssm_mem_statistics_pool_t
Statistics for a heap page pool; used in ssm_mem_statistics_t.
void ssm_mem_statistics_collect(ssm_mem_statistics_t *stats)
Collect and return statistics about the heap.
void ssm_mem_init(void *(*alloc_page_handler)(void), void *(*alloc_mem_handler)(size_t), void(*free_mem_handler)(void *, size_t))
Initializes the underlying allocator system.
void ssm_unschedule(ssm_sv_t *var)
Unschedule any pending events on a variable.
void ssm_update(ssm_sv_t *sv)
Perform a (delayed) update on a variable.
void ssm_reset(void)
Reset the scheduler.
void ssm_set_now(ssm_time_t next)
Advance the current model time.
ssm_time_t ssm_next_event_time(void)
The time of the next event in the event queue.
uint64_t ssm_time_t
Absolute time; never to overflow.
Interface to the SSM runtime.
Statistics for a heap page pool; used in ssm_mem_statistics_t.
size_t pages_allocated
Number of pages allocated to this pool.
size_t free_list_length
Length of the free list.
size_t block_size
Size of this pool's blocks.
Statistics for the heap; filled with ssm_mem_statistics_collect().
size_t pages_allocated
Number of pages that have been allocated.
size_t sizeof_ssm_mm
Size of per-object memory management header.
ssm_mem_statistics_pool_t pool[32]
Size of the blocks in each pool.
size_t live_objects
Number of live objects.
size_t objects_allocated
Total number of allocated objects.
size_t pool_count
Number of memory pools.
size_t objects_freed
Total number of object free events.
size_t page_size
Bytes in a memory page.
A scheduled variable that supports scheduled updates with triggers.