KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
reentrant_mutex.c File Reference
#include <kos.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <stdnoreturn.h>

Macros

#define THREAD_COUNT   (DBL_MEM? 600 : 300)
 
#define THREAD_PASS_CHANCE   75
 

Functions

static void reentrant_mutex_init (reentrant_mutex_t *rmutex)
 
static void reentrant_mutex_uninit (reentrant_mutex_t *rmutex)
 
static noreturn void failure (const char *fmt,...)
 
static void reentrant_mutex_lock (reentrant_mutex_t *rmutex)
 
static void reentrant_mutex_unlock (reentrant_mutex_t *rmutex)
 
static void maybe_pass (void)
 
static void * thread_func (void *arg)
 
int main (int argc, const char *argv[])
 

Variables

static reentrant_mutex_t rmutex
 
static int shared_variable = 0
 

Macro Definition Documentation

◆ THREAD_COUNT

#define THREAD_COUNT   (DBL_MEM? 600 : 300)

Referenced by main().

◆ THREAD_PASS_CHANCE

#define THREAD_PASS_CHANCE   75

Referenced by maybe_pass().

Function Documentation

◆ failure()

static noreturn void failure ( const char * fmt,
... )
static

◆ main()

◆ maybe_pass()

static void maybe_pass ( void )
static

References thd_pass(), and THREAD_PASS_CHANCE.

Referenced by main(), and thread_func().

◆ reentrant_mutex_init()

static void reentrant_mutex_init ( reentrant_mutex_t * rmutex)
static

References mutex_init(), MUTEX_TYPE_NORMAL, NULL, and rmutex.

Referenced by main().

◆ reentrant_mutex_lock()

static void reentrant_mutex_lock ( reentrant_mutex_t * rmutex)
static

◆ reentrant_mutex_uninit()

static void reentrant_mutex_uninit ( reentrant_mutex_t * rmutex)
static

References mutex_destroy(), and rmutex.

Referenced by main().

◆ reentrant_mutex_unlock()

static void reentrant_mutex_unlock ( reentrant_mutex_t * rmutex)
static

References _Atomic(), failure(), fprintf, mutex_unlock(), NULL, and rmutex.

Referenced by thread_func().

◆ thread_func()

static void * thread_func ( void * arg)
static

Variable Documentation

◆ rmutex

◆ shared_variable

int shared_variable = 0
static

Referenced by main(), and thread_func().