smp.h
Include dependency graph for smp.h:
This graph shows which files directly or indirectly include smp.h:
Multicore support functions.
This header defines multicore support functions to be implemented for SMP builds.
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:
-
-
void smp_mutex_lock(Mutex *mtx)
Lock a mutex.
- Parameters:
-
-
bool smp_mutex_trylock(Mutex *mtx)
Try and lock a mutex.
- Parameters:
-
- Returns:
true
if the mutex was acquired.
-
void smp_mutex_unlock(Mutex *mtx)
Unlock a mutex.
- Parameters:
-
-
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:
-
-
void smp_condvar_wait(CondVar *cv, Mutex *mtx)
Wait on a condition variable, atomically unlocking the mutex.
- Parameters:
-
-
void smp_condvar_signal(CondVar *cv)
Signal a single thread waiting on a condition variable.
- Parameters:
-
-
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:
-
-
void smp_rwlock_rdlock(RWLock *lock)
Read lock a rwlock.
- Parameters:
-
-
bool smp_rwlock_tryrdlock(RWLock *lock)
Try to acquire read lock of a rwlock.
- Parameters:
-
- Returns:
true
if lock was acquired
-
void smp_rwlock_wrlock(RWLock *lock)
Write lock a rwlock.
- Parameters:
-
-
void smp_rwlock_unlock(RWLock *lock)
Unlock a rwlock.
- Parameters:
-
-
static inline void smp_spinlock_init(SpinLock *lock)
Initialize a spinlock based on atomics.
- Parameters:
-
-
static inline void smp_spinlock_lock(SpinLock *lock)
Lock a spinlock.
- Parameters:
-
-
static inline bool smp_spinlock_trylock(SpinLock *lock)
Try to lock a spinlock.
- Parameters:
-
- Returns:
true if the spin lock was locked
-
static inline void smp_spinlock_unlock(SpinLock *lock)
Unlock a spinlock.
- Parameters:
-
-
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:
-
-
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>