smp.h

Include dependency graph for smp.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="stdbool.h" tooltip="stdbool.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/smp.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/smp.h" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include smp.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "7" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.c"]
    "50" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/dictionary.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/dictionary.c"]
    "6" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/bif.h"]
    "30" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/platform_nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/platform_nifs.h"]
    "17" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.c"]
    "52" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/posix_nifs.h"]
    "53" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/synclist.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/synclist.h"]
    "49" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/defaultatoms.h"]
    "24" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.c"]
    "55" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/valueshashtable.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/valueshashtable.c"]
    "23" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/inet.h"]
    "43" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/scheduler.h"]
    "4" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.c"]
    "5" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/context.h"]
    "41" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.c"]
    "42" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/port.h"]
    "20" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets.c"]
    "54" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets.h"]
    "2" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/atom_table.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/atom_table.c"]
    "32" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.c"]
    "31" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/stacktrace.h"]
    "18" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/refc_binary.c"]
    "44" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/mailbox.c"]
    "8" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.c"]
    "29" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/module.h"]
    "48" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.c"]
    "47" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/avmpack.h"]
    "28" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/term.c"]
    "26" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.c"]
    "16" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.c"]
    "22" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/interop.h"]
    "38" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_ssl.h"]
    "40" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/portnifloader.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/portnifloader.c"]
    "39" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/portnifloader.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/portnifloader.h"]
    "19" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/resources.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/resources.c"]
    "27" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.c"]
    "35" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_crypto.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/smp.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/smp.h" fillcolor="#BFBFBF"]
    "25" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.c"]
    "45" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets_hashtable.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets_hashtable.c"]
    "36" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_net.h"]
    "51" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets_hashtable.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/ets_hashtable.h"]
    "13" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/erl_nif_priv.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/erl_nif_priv.h"]
    "33" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/sys.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/sys.h"]
    "3" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/atomshashtable.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/atomshashtable.c"]
    "9" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.c"]
    "34" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/nifs.h"]
    "11" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.c"]
    "10" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/debug.h"]
    "14" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.c"]
    "46" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/globalcontext.h"]
    "12" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/memory.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/memory.c"]
    "15" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c"]
    "37" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.h" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.h"]
    "21" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/externalterm.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/externalterm.c"]
    "6" -> "7" [dir=back tooltip="include"]
    "6" -> "8" [dir=back tooltip="include"]
    "6" -> "9" [dir=back tooltip="include"]
    "30" -> "9" [dir=back tooltip="include"]
    "52" -> "14" [dir=back tooltip="include"]
    "52" -> "9" [dir=back tooltip="include"]
    "52" -> "15" [dir=back tooltip="include"]
    "52" -> "17" [dir=back tooltip="include"]
    "53" -> "4" [dir=back tooltip="include"]
    "53" -> "54" [dir=back tooltip="include"]
    "53" -> "14" [dir=back tooltip="include"]
    "53" -> "46" [dir=back tooltip="include"]
    "53" -> "44" [dir=back tooltip="include"]
    "53" -> "9" [dir=back tooltip="include"]
    "49" -> "7" [dir=back tooltip="include"]
    "49" -> "50" [dir=back tooltip="include"]
    "49" -> "20" [dir=back tooltip="include"]
    "49" -> "14" [dir=back tooltip="include"]
    "49" -> "26" [dir=back tooltip="include"]
    "49" -> "9" [dir=back tooltip="include"]
    "49" -> "27" [dir=back tooltip="include"]
    "49" -> "25" [dir=back tooltip="include"]
    "49" -> "15" [dir=back tooltip="include"]
    "49" -> "16" [dir=back tooltip="include"]
    "49" -> "41" [dir=back tooltip="include"]
    "49" -> "42" [dir=back tooltip="include"]
    "49" -> "17" [dir=back tooltip="include"]
    "49" -> "19" [dir=back tooltip="include"]
    "49" -> "32" [dir=back tooltip="include"]
    "23" -> "24" [dir=back tooltip="include"]
    "23" -> "25" [dir=back tooltip="include"]
    "23" -> "15" [dir=back tooltip="include"]
    "23" -> "16" [dir=back tooltip="include"]
    "43" -> "14" [dir=back tooltip="include"]
    "43" -> "44" [dir=back tooltip="include"]
    "43" -> "9" [dir=back tooltip="include"]
    "43" -> "15" [dir=back tooltip="include"]
    "5" -> "6" [dir=back tooltip="include"]
    "5" -> "4" [dir=back tooltip="include"]
    "5" -> "10" [dir=back tooltip="include"]
    "5" -> "13" [dir=back tooltip="include"]
    "5" -> "20" [dir=back tooltip="include"]
    "5" -> "21" [dir=back tooltip="include"]
    "5" -> "14" [dir=back tooltip="include"]
    "5" -> "22" [dir=back tooltip="include"]
    "5" -> "12" [dir=back tooltip="include"]
    "5" -> "8" [dir=back tooltip="include"]
    "5" -> "29" [dir=back tooltip="include"]
    "5" -> "9" [dir=back tooltip="include"]
    "5" -> "34" [dir=back tooltip="include"]
    "5" -> "27" [dir=back tooltip="include"]
    "5" -> "25" [dir=back tooltip="include"]
    "5" -> "15" [dir=back tooltip="include"]
    "5" -> "16" [dir=back tooltip="include"]
    "5" -> "41" [dir=back tooltip="include"]
    "5" -> "42" [dir=back tooltip="include"]
    "5" -> "39" [dir=back tooltip="include"]
    "5" -> "18" [dir=back tooltip="include"]
    "5" -> "19" [dir=back tooltip="include"]
    "5" -> "43" [dir=back tooltip="include"]
    "5" -> "31" [dir=back tooltip="include"]
    "5" -> "28" [dir=back tooltip="include"]
    "42" -> "24" [dir=back tooltip="include"]
    "42" -> "9" [dir=back tooltip="include"]
    "42" -> "25" [dir=back tooltip="include"]
    "42" -> "15" [dir=back tooltip="include"]
    "42" -> "16" [dir=back tooltip="include"]
    "42" -> "41" [dir=back tooltip="include"]
    "54" -> "20" [dir=back tooltip="include"]
    "54" -> "46" [dir=back tooltip="include"]
    "54" -> "9" [dir=back tooltip="include"]
    "31" -> "32" [dir=back tooltip="include"]
    "29" -> "6" [dir=back tooltip="include"]
    "29" -> "8" [dir=back tooltip="include"]
    "29" -> "9" [dir=back tooltip="include"]
    "29" -> "30" [dir=back tooltip="include"]
    "29" -> "31" [dir=back tooltip="include"]
    "29" -> "33" [dir=back tooltip="include"]
    "29" -> "28" [dir=back tooltip="include"]
    "47" -> "48" [dir=back tooltip="include"]
    "47" -> "14" [dir=back tooltip="include"]
    "47" -> "9" [dir=back tooltip="include"]
    "22" -> "23" [dir=back tooltip="include"]
    "22" -> "26" [dir=back tooltip="include"]
    "22" -> "9" [dir=back tooltip="include"]
    "22" -> "27" [dir=back tooltip="include"]
    "22" -> "25" [dir=back tooltip="include"]
    "22" -> "15" [dir=back tooltip="include"]
    "22" -> "16" [dir=back tooltip="include"]
    "22" -> "17" [dir=back tooltip="include"]
    "22" -> "28" [dir=back tooltip="include"]
    "38" -> "16" [dir=back tooltip="include"]
    "39" -> "40" [dir=back tooltip="include"]
    "35" -> "27" [dir=back tooltip="include"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "3" [dir=back tooltip="include"]
    "1" -> "4" [dir=back tooltip="include"]
    "1" -> "5" [dir=back tooltip="include"]
    "1" -> "45" [dir=back tooltip="include"]
    "1" -> "14" [dir=back tooltip="include"]
    "1" -> "46" [dir=back tooltip="include"]
    "1" -> "8" [dir=back tooltip="include"]
    "1" -> "9" [dir=back tooltip="include"]
    "1" -> "53" [dir=back tooltip="include"]
    "1" -> "55" [dir=back tooltip="include"]
    "36" -> "25" [dir=back tooltip="include"]
    "51" -> "20" [dir=back tooltip="include"]
    "51" -> "45" [dir=back tooltip="include"]
    "13" -> "4" [dir=back tooltip="include"]
    "13" -> "14" [dir=back tooltip="include"]
    "13" -> "12" [dir=back tooltip="include"]
    "13" -> "15" [dir=back tooltip="include"]
    "13" -> "16" [dir=back tooltip="include"]
    "13" -> "17" [dir=back tooltip="include"]
    "13" -> "18" [dir=back tooltip="include"]
    "13" -> "19" [dir=back tooltip="include"]
    "33" -> "4" [dir=back tooltip="include"]
    "33" -> "14" [dir=back tooltip="include"]
    "33" -> "8" [dir=back tooltip="include"]
    "33" -> "9" [dir=back tooltip="include"]
    "33" -> "15" [dir=back tooltip="include"]
    "33" -> "19" [dir=back tooltip="include"]
    "34" -> "8" [dir=back tooltip="include"]
    "34" -> "9" [dir=back tooltip="include"]
    "34" -> "27" [dir=back tooltip="include"]
    "34" -> "35" [dir=back tooltip="include"]
    "34" -> "25" [dir=back tooltip="include"]
    "34" -> "36" [dir=back tooltip="include"]
    "34" -> "15" [dir=back tooltip="include"]
    "34" -> "37" [dir=back tooltip="include"]
    "34" -> "16" [dir=back tooltip="include"]
    "34" -> "38" [dir=back tooltip="include"]
    "34" -> "39" [dir=back tooltip="include"]
    "34" -> "17" [dir=back tooltip="include"]
    "10" -> "11" [dir=back tooltip="include"]
    "10" -> "12" [dir=back tooltip="include"]
    "46" -> "47" [dir=back tooltip="include"]
    "46" -> "4" [dir=back tooltip="include"]
    "46" -> "5" [dir=back tooltip="include"]
    "46" -> "49" [dir=back tooltip="include"]
    "46" -> "51" [dir=back tooltip="include"]
    "46" -> "14" [dir=back tooltip="include"]
    "46" -> "12" [dir=back tooltip="include"]
    "46" -> "8" [dir=back tooltip="include"]
    "46" -> "29" [dir=back tooltip="include"]
    "46" -> "9" [dir=back tooltip="include"]
    "46" -> "27" [dir=back tooltip="include"]
    "46" -> "25" [dir=back tooltip="include"]
    "46" -> "36" [dir=back tooltip="include"]
    "46" -> "15" [dir=back tooltip="include"]
    "46" -> "37" [dir=back tooltip="include"]
    "46" -> "16" [dir=back tooltip="include"]
    "46" -> "38" [dir=back tooltip="include"]
    "46" -> "41" [dir=back tooltip="include"]
    "46" -> "42" [dir=back tooltip="include"]
    "46" -> "39" [dir=back tooltip="include"]
    "46" -> "17" [dir=back tooltip="include"]
    "46" -> "52" [dir=back tooltip="include"]
    "46" -> "43" [dir=back tooltip="include"]
    "46" -> "32" [dir=back tooltip="include"]
    "46" -> "33" [dir=back tooltip="include"]
    "37" -> "15" [dir=back tooltip="include"]
    "37" -> "16" [dir=back tooltip="include"]
}

Multicore support functions.

This header defines multicore support functions to be implemented for SMP builds.

Defines

CLANG_THREAD_SANITIZE_SAFE
ATOMIC
TYPEDEF_MUTEX
TYPEDEF_SPINLOCK
TYPEDEF_CONDVAR
TYPEDEF_RWLOCK
TYPEDEF_GLOBALCONTEXT
SMP_SPINLOCK_LOCK(spinlock) smp_spinlock_lock(spinlock)
SMP_SPINLOCK_TRYLOCK(spinlock) smp_spinlock_trylock(spinlock)
SMP_SPINLOCK_UNLOCK(spinlock) smp_spinlock_unlock(spinlock)
SMP_MUTEX_LOCK(mutex) smp_mutex_lock(mutex)
SMP_MUTEX_TRYLOCK(mutex) smp_mutex_trylock(mutex)
SMP_MUTEX_UNLOCK(mutex) smp_mutex_unlock(mutex)
SMP_RWLOCK_RDLOCK(lock) smp_rwlock_rdlock(lock)
SMP_RWLOCK_TRYRDLOCK(lock) smp_rwlock_tryrdlock(lock)
SMP_RWLOCK_WRLOCK(lock) smp_rwlock_wrlock(lock)
SMP_RWLOCK_UNLOCK(lock) smp_rwlock_unlock(lock)

Typedefs

typedef struct Mutex Mutex
typedef struct SpinLock SpinLock
typedef struct CondVar CondVar
typedef struct RWLock RWLock
typedef struct GlobalContext GlobalContext

Functions

Mutex *smp_mutex_create()

Create a new mutex.

Returns:

a pointer to a mutex.

void smp_mutex_destroy(Mutex *mtx)

Destroy a mutex.

Parameters:
  • mtx – the mutex to destroy

void smp_mutex_lock(Mutex *mtx)

Lock a mutex.

Parameters:
  • mtx – the mutex to lock

bool smp_mutex_trylock(Mutex *mtx)

Try and lock a mutex.

Parameters:
  • mtx – the mutex to lock

Returns:

true if the mutex was acquired.

void smp_mutex_unlock(Mutex *mtx)

Unlock a mutex.

Parameters:
  • mtx – the mutex to unlock

CondVar *smp_condvar_create()

Create a new condition variable.

Returns:

a pointer to a cv.

void smp_condvar_destroy(CondVar *cv)

Destroy a condition variable.

Parameters:
  • cv – variable to destroy.

void smp_condvar_wait(CondVar *cv, Mutex *mtx)

Wait on a condition variable, atomically unlocking the mutex.

Parameters:
  • cv – variable to wait on.

  • mtx – mutex to unlock/lock.

void smp_condvar_signal(CondVar *cv)

Signal a single thread waiting on a condition variable.

Parameters:
  • cv – variable to signal.

RWLock *smp_rwlock_create()

Create a new rwlock.

A RW Lock can be replaced by a mutex if RW Lock are not available on the platform.

Returns:

a pointer to a lock.

void smp_rwlock_destroy(RWLock *lock)

Destroy a rwlock.

Parameters:
  • lock – the lock to destroy

void smp_rwlock_rdlock(RWLock *lock)

Read lock a rwlock.

Parameters:
  • lock – the lock to read lock

bool smp_rwlock_tryrdlock(RWLock *lock)

Try to acquire read lock of a rwlock.

Parameters:
  • lock – the lock to read lock

Returns:

true if lock was acquired

void smp_rwlock_wrlock(RWLock *lock)

Write lock a rwlock.

Parameters:
  • lock – the lock to write lock

void smp_rwlock_unlock(RWLock *lock)

Unlock a rwlock.

Parameters:
  • lock – the lock to unlock

static inline void smp_spinlock_init(SpinLock *lock)

Initialize a spinlock based on atomics.

Parameters:
  • lock – the spin lock to initialize

static inline void smp_spinlock_lock(SpinLock *lock)

Lock a spinlock.

Parameters:
  • lock – the spin lock to lock

static inline bool smp_spinlock_trylock(SpinLock *lock)

Try to lock a spinlock.

Parameters:
  • lock – the spin lock to lock

Returns:

true if the spin lock was locked

static inline void smp_spinlock_unlock(SpinLock *lock)

Unlock a spinlock.

Parameters:
  • lock – the spin lock to unlock

int smp_get_online_processors()

Get the number of online processors to configure schedulers.

This value is one plus the maximum number of times smp_scheduler_start will be called by the scheduler.

Returns:

the number of online processors.

void smp_scheduler_start(GlobalContext *glb)

Start a new scheduler, calling scheduler_entry_point with the given global context.

Parameters:
  • glb – the global context

bool smp_is_main_thread(GlobalContext *glb)

Determine if caller is in the main thread, i.e. thread that was not started with acmsmp_scheduler_start.

struct SpinLock
#include <smp.h>

Public Members

int lock