28#define MUTEX_TESTS(X) \
29 X("mutex::init", test_mutex_init), X("mutex::uncontended", test_mutex_uncontended), \
30 X("mutex::mutual_exclusion", test_mutex_mutual_exclusion), \
31 X("mutex::fifo_order", test_mutex_fifo_order), \
32 X("mutex::mt_contention", test_mutex_mt_contention)
38 return atomic_load_explicit(&
test_mtx.state, memory_order_relaxed);
134 int id = (int)(intptr_t)arg;
188#define MTX_MT_ITERS 100
212 for (
int i = 0; i <
MTX_MT_N; i++) {
#define RELEASE_CONTEXT(x)
#define ASSERT_NOT_NULL(x)
#define SHUTDOWN_ENGINE(mm, engine)
#define MAKE_ENGINE(mm, engine)
#define MAKE_CONTEXT(engine, x)
srn_fiber_t * srn_fiber_spawn(srn_context_t *ctx, srn_fiber_entry_t entry, void *arg)
Make and schedule a fiber with every default, the engine's scheduler, the configured stack size,...
AI Generated (🤦) Fiber subsystem overview.
void * srn_fiber_result_t
What a fiber's entry produces, type-erased.
void srn_fiber_mutex_init(srn_fiber_mutex_t *m)
Initialise m to the unlocked state.
void srn_fiber_mutex_unlock(srn_fiber_mutex_t *m)
Release m.
void srn_fiber_mutex_lock(srn_fiber_mutex_t *m)
Acquire m.
static srn_fiber_result_t test_mtx_mt_entry(srn_context_t *ctx, void *arg)
static srn_fiber_result_t test_mtx_fifo_waiter_entry(srn_context_t *ctx, void *arg)
static int test_mtx_fifo_n
static srn_fiber_mutex_t test_mtx
static long test_mtx_mt_counter
static void test_mutex_init()
static int test_mtx_me_counter
static srn_fiber_result_t test_mtx_me_entry(srn_context_t *ctx, void *arg)
static void test_mutex_mt_contention()
static srn_fiber_result_t test_mtx_fifo_holder_entry(srn_context_t *ctx, void *arg)
static void test_mutex_uncontended()
static srn_fiber_t * test_mtx_state(void)
static srn_fiber_result_t test_mtx_uncontended_entry(srn_context_t *ctx, void *arg)
static void test_mutex_mutual_exclusion()
static int test_mtx_fifo_order[MTX_FIFO_N]
static bool test_mtx_uncontended_ran
static void test_mutex_fifo_order()
void srn_sched_run(srn_scheduler_t *sched, size_t nworkers)
Run the scheduler with nworkers os threads draining it, returning once the pool goes quiescent (every...
void srn_fiber_yield(void)
Yield cooperatively, re-enqueue the running fiber and run the next ready one.