Motr  M0
sim.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <err.h>
#include <signal.h>
#include <sysexits.h>
#include <execinfo.h>
#include "motr/magic.h"
#include "lib/assert.h"
#include "desim/sim.h"
Include dependency graph for sim.c:

Go to the source code of this file.

Functions

 M0_TL_DESCR_DEFINE (ca, "call-outs", static, struct sim_callout, sc_linkage, sc_magic, M0_DESIM_SIM_CALLOUT_MAGIC, M0_DESIM_SIM_CALLOUT_HEAD_MAGIC)
 
 M0_TL_DEFINE (ca, static, struct sim_callout)
 
 M0_TL_DESCR_DEFINE (sim_thr, "threads", static, struct sim_thread, st_block, st_magic, M0_DESIM_SIM_THREAD_MAGIC, M0_DESIM_SIM_THREAD_HEAD_MAGIC)
 
 M0_TL_DEFINE (sim_thr, static, struct sim_thread)
 
int vasprintf (char **strp, const char *fmt, va_list ap)
 
M0_INTERNAL void * sim_alloc (size_t size)
 
M0_INTERNAL void sim_free (void *ptr)
 
M0_INTERNAL void sim_init (struct sim *state)
 
M0_INTERNAL void sim_fini (struct sim *state)
 
M0_INTERNAL void sim_run (struct sim *state)
 
static void sim_call_place (struct sim *sim, struct sim_callout *call)
 
static void sim_timer_init (struct sim *state, struct sim_callout *call, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
M0_INTERNAL void sim_timer_add (struct sim *state, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
M0_INTERNAL void sim_timer_rearm (struct sim_callout *call, sim_time_t delta, sim_call_t *cfunc, void *datum)
 
static void sim_thread_fix (struct sim_thread *thread)
 
static void sim_thread_resume (struct sim_thread *thread)
 
static void sim_thread_suspend (struct sim_thread *thread)
 
static void * sim_decode (int p0, int p1)
 
static int sim_encode0 (void *p)
 
static int sim_encode1 (void *p)
 
static void sim_trampoline (int func0, int func1, int state0, int state1, int thread0, int thread1, int datum0, int datum1)
 
M0_INTERNAL void sim_thread_init (struct sim *state, struct sim_thread *thread, unsigned stacksize, sim_func_t func, void *arg)
 
M0_INTERNAL void sim_thread_fini (struct sim_thread *thread)
 
M0_INTERNAL void sim_thread_exit (struct sim_thread *thread)
 
static int sim_wakeup (struct sim_callout *call)
 
static void sim_wakeup_post (struct sim *sim, struct sim_thread *thread, sim_time_t nap)
 
M0_INTERNAL void sim_sleep (struct sim_thread *thread, sim_time_t nap)
 
M0_INTERNAL void sim_chan_init (struct sim_chan *chan, char *format,...)
 
M0_INTERNAL void sim_chan_fini (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_wait (struct sim_chan *chan, struct sim_thread *thread)
 
static void sim_chan_wake_head (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_signal (struct sim_chan *chan)
 
M0_INTERNAL void sim_chan_broadcast (struct sim_chan *chan)
 
M0_INTERNAL struct sim_threadsim_thread_current (void)
 
M0_INTERNAL unsigned long long sim_rnd (unsigned long long a, unsigned long long b)
 
M0_INTERNAL void sim_name_set (char **name, const char *format,...)
 
M0_INTERNAL void sim_name_vaset (char **name, const char *format, va_list valist)
 
M0_INTERNAL void sim_log (struct sim *s, enum sim_log_level level, const char *format,...)
 
M0_INTERNAL int sim_global_init (void)
 
M0_INTERNAL void sim_global_fini (void)
 

Variables

static struct sim_threadsim_current = NULL
 
static ucontext_t sim_idle_ctx
 
enum sim_log_level sim_log_level = SLL_INFO