![]() |
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Minimal POSIX-threads-style interface for SuperTinyKernel RTOS. More...
Classes | |
| struct | pthread_attr_t |
| Thread creation attributes. More... | |
| struct | pthread_mutexattr_t |
| Mutex attributes. More... | |
| struct | pthread_mutex_t |
| A pthread mutex. More... | |
| struct | pthread_condattr_t |
| Condition variable attributes (currently no settable properties). More... | |
| struct | pthread_cond_t |
| A pthread condition variable. More... | |
| struct | pthread_rwlockattr_t |
| Read-write lock attributes (currently no settable properties). More... | |
| struct | pthread_rwlock_t |
| A pthread read-write lock. More... | |
| struct | pthread_spinlock_t |
| A pthread spinlock. More... | |
| struct | pthread_barrierattr_t |
| Barrier attributes (currently no settable properties). More... | |
| struct | pthread_barrier_t |
| A pthread barrier. More... | |
| struct | pthread_once_t |
| A pthread_once() control object. More... | |
Macros | |
| #define | STK_C_PTHREAD_VERSION (0x20261004) |
| Interface version. | |
| #define | STK_C_PTHREAD_MAX_THREADS (8U) |
| Maximum number of concurrently-alive pthread_t's (default: 8). | |
| #define | STK_C_PTHREAD_DEFAULT_STACK_WORDS (1024U) |
| Default per-thread stack size in stk_word_t units, used when pthread_attr_t does not specify a stack size or an external stack (default: 1024 words). | |
| #define | STK_C_PTHREAD_REAPER_STACK_WORDS (256U) |
| Stack size (in stk_word_t units) for the internal reaper task that reclaims detached-thread resources (default: 256 words). | |
| #define | STK_C_PTHREAD_KEYS_MAX (8U) |
| Maximum number of concurrently-alive pthread_key_t's (default: 8). | |
| #define | PTHREAD_CREATE_JOINABLE (0) |
| #define | PTHREAD_CREATE_DETACHED (1) |
| #define | PTHREAD_CREATE_USER_NP (0) |
| #define | PTHREAD_CREATE_PRIVILEGED_NP (1) |
| #define | PTHREAD_MUTEX_NORMAL (0) |
| #define | PTHREAD_MUTEX_DEFAULT (PTHREAD_MUTEX_NORMAL) |
| #define | PTHREAD_MUTEX_ERRORCHECK (1) |
| #define | PTHREAD_MUTEX_RECURSIVE (2) |
| #define | PTHREAD_MUTEX_INITIALIZER {0} |
| #define | PTHREAD_COND_INITIALIZER {0} |
| #define | PTHREAD_RWLOCK_INITIALIZER {0} |
| #define | PTHREAD_PROCESS_PRIVATE (0) |
| #define | PTHREAD_PROCESS_SHARED (1) |
| #define | PTHREAD_BARRIER_SERIAL_THREAD (-1) |
| Returned by pthread_barrier_wait() to exactly one arbitrary caller per round; all others receive 0. See "pthread_barrier_wait() note" in the file-level docs. | |
| #define | PTHREAD_ONCE_INIT {0} |
| #define | PTHREAD_KEYS_MAX (STK_C_PTHREAD_KEYS_MAX) |
| POSIX-standard name for STK_C_PTHREAD_KEYS_MAX (this file). | |
| #define | PTHREAD_DESTRUCTOR_ITERATIONS (4) |
| Maximum number of passes over a finishing thread's keys made while destructors keep setting new non-NULL values for their own key. See "pthread_key_t / thread-specific data" in the file-level docs. | |
Typedefs | |
| typedef struct pthread_stk_ctrl_t * | pthread_t |
| Opaque thread handle. | |
| typedef struct pthread_attr_t | pthread_attr_t |
| Thread creation attributes. | |
| typedef struct pthread_mutexattr_t | pthread_mutexattr_t |
| Mutex attributes. | |
| typedef struct pthread_mutex_t | pthread_mutex_t |
| A pthread mutex. | |
| typedef struct pthread_condattr_t | pthread_condattr_t |
| Condition variable attributes (currently no settable properties). | |
| typedef struct pthread_cond_t | pthread_cond_t |
| A pthread condition variable. | |
| typedef struct pthread_rwlockattr_t | pthread_rwlockattr_t |
| Read-write lock attributes (currently no settable properties). | |
| typedef struct pthread_rwlock_t | pthread_rwlock_t |
| A pthread read-write lock. | |
| typedef struct pthread_spinlock_t | pthread_spinlock_t |
| A pthread spinlock. | |
| typedef struct pthread_barrierattr_t | pthread_barrierattr_t |
| Barrier attributes (currently no settable properties). | |
| typedef struct pthread_barrier_t | pthread_barrier_t |
| A pthread barrier. | |
| typedef struct pthread_once_t | pthread_once_t |
| A pthread_once() control object. | |
| typedef unsigned int | pthread_key_t |
| A thread-specific data key. | |
Functions | |
| void | stk_pthread_bind_kernel (stk_kernel_t *kernel) |
| Bind the STK kernel instance that pthread_create() will add new threads to. | |
| int | pthread_attr_init (pthread_attr_t *attr) |
| Initialize a thread attributes object with default values (default stack size, no external stack, joinable). | |
| int | pthread_attr_destroy (pthread_attr_t *attr) |
| Destroy a thread attributes object (no-op; no owned resources). | |
| int | pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) |
| Set the requested stack size in bytes. | |
| int | pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize) |
| Get the stack size in bytes that threads created with attr will use. | |
| int | pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize) |
| Supply an external, caller-owned stack buffer for the thread. | |
| int | pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) |
| Get the previously-set external stack (stackaddr is NULL if none set). | |
| int | pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) |
| Set PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. | |
| int | pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) |
| Get the current detach-state setting. | |
| int | pthread_attr_setprivileged_np (pthread_attr_t *attr, int mode) |
| Non-portable: select the STK access mode of threads created with attr. | |
| int | pthread_attr_getprivileged_np (const pthread_attr_t *attr, int *mode) |
| Non-portable: get the access mode set in attr. | |
| int | pthread_create (pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) |
| Create and start a new thread. | |
| int | pthread_join (pthread_t thread, void **retval) |
| Block until the given joinable thread finishes, then reclaim its resources. | |
| int | pthread_detach (pthread_t thread) |
| Mark a thread as detached. | |
| void | pthread_exit (void *retval) |
| Terminate the calling thread. | |
| pthread_t | pthread_self (void) |
| Return the calling thread's own handle. | |
| int | pthread_equal (pthread_t t1, pthread_t t2) |
| Compare two thread handles for equality. | |
| int | pthread_yield (void) |
| Voluntarily give up the CPU to another ready task (cooperative yield), then resume once rescheduled. | |
| int | pthread_mutexattr_init (pthread_mutexattr_t *attr) |
| Initialize a mutex attributes object with default values (PTHREAD_MUTEX_DEFAULT). | |
| int | pthread_mutexattr_destroy (pthread_mutexattr_t *attr) |
| Destroy a mutex attributes object (no-op; no owned resources). | |
| int | pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type) |
| Set the mutex type. | |
| int | pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type) |
| Get the mutex type stored in attr. | |
| int | pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) |
| Initialize a mutex. | |
| int | pthread_mutex_destroy (pthread_mutex_t *mutex) |
| Destroy a mutex, releasing the underlying STK mutex object. | |
| int | pthread_mutex_lock (pthread_mutex_t *mutex) |
| Lock a mutex, blocking until it becomes available. | |
| int | pthread_mutex_trylock (pthread_mutex_t *mutex) |
| Try to lock a mutex without blocking. | |
| int | pthread_mutex_unlock (pthread_mutex_t *mutex) |
| Unlock a mutex held by the calling thread. | |
| int | pthread_mutex_timedlock (pthread_mutex_t *mutex, const struct timespec *abstime) |
| Lock with an absolute deadline. | |
| int | pthread_condattr_init (pthread_condattr_t *attr) |
| Initialize a condition variable attributes object (no settable properties). | |
| int | pthread_condattr_destroy (pthread_condattr_t *attr) |
| Destroy a condition variable attributes object (no-op). | |
| int | pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) |
| Initialize a condition variable. | |
| int | pthread_cond_destroy (pthread_cond_t *cond) |
| Destroy a condition variable, releasing the underlying STK object. | |
| int | pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) |
| Atomically unlock mutex and wait for a signal; re-locks mutex before returning. | |
| int | pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) |
| As pthread_cond_wait(), with an absolute deadline. | |
| int | pthread_cond_signal (pthread_cond_t *cond) |
| Wake one thread waiting on cond (no effect if none is waiting). | |
| int | pthread_cond_broadcast (pthread_cond_t *cond) |
| Wake all threads waiting on cond (no effect if none is waiting). | |
| int | pthread_rwlockattr_init (pthread_rwlockattr_t *attr) |
| Initialize a read-write lock attributes object (no settable properties). | |
| int | pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr) |
| Destroy a read-write lock attributes object (no-op). | |
| int | pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) |
| Initialize a read-write lock. | |
| int | pthread_rwlock_destroy (pthread_rwlock_t *rwlock) |
| Destroy a read-write lock, releasing the underlying STK object. | |
| int | pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) |
| Acquire the lock for shared reading. Blocks until available. | |
| int | pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) |
| Try to acquire the read lock without blocking. | |
| int | pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock, const struct timespec *abstime) |
| Acquire the read lock with an absolute deadline. | |
| int | pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) |
| Acquire the lock for exclusive writing. Blocks until available. | |
| int | pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) |
| Try to acquire the write lock without blocking. | |
| int | pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, const struct timespec *abstime) |
| Acquire the write lock with an absolute deadline. | |
| int | pthread_rwlock_unlock (pthread_rwlock_t *rwlock) |
| Release a read or write hold, whichever the calling thread holds. | |
| int | pthread_spin_init (pthread_spinlock_t *lock, int pshared) |
| Initialize a spinlock. | |
| int | pthread_spin_destroy (pthread_spinlock_t *lock) |
| Destroy a spinlock. | |
| int | pthread_spin_lock (pthread_spinlock_t *lock) |
| Acquire the spinlock, spinning until available. | |
| int | pthread_spin_trylock (pthread_spinlock_t *lock) |
| Try to acquire the spinlock without blocking. | |
| int | pthread_spin_unlock (pthread_spinlock_t *lock) |
| Release a spinlock held by the calling thread. | |
| int | pthread_barrierattr_init (pthread_barrierattr_t *attr) |
| Initialize a barrier attributes object (no settable properties). | |
| int | pthread_barrierattr_destroy (pthread_barrierattr_t *attr) |
| Destroy a barrier attributes object (no-op). | |
| int | pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) |
| Initialize a barrier for count participating threads. | |
| int | pthread_barrier_destroy (pthread_barrier_t *barrier) |
| Destroy a barrier, releasing the underlying STK barrier object. | |
| int | pthread_barrier_wait (pthread_barrier_t *barrier) |
| Block until count threads have called this function, then release them all together; the barrier resets for reuse. | |
| int | pthread_once (pthread_once_t *once_control, void(*init_routine)(void)) |
| Call init_routine exactly once for a given once_control, no matter how many threads call pthread_once() on it concurrently. | |
| int | pthread_key_create (pthread_key_t *key, void(*destructor)(void *)) |
| Allocate a new thread-specific data key. | |
| int | pthread_key_delete (pthread_key_t key) |
| Free a thread-specific data key. | |
| int | pthread_setspecific (pthread_key_t key, const void *value) |
| Set the calling thread's value for key. | |
| void * | pthread_getspecific (pthread_key_t key) |
| Get the calling thread's value for key. | |
Minimal POSIX-threads-style interface for SuperTinyKernel RTOS.
| #define PTHREAD_BARRIER_SERIAL_THREAD (-1) |
Returned by pthread_barrier_wait() to exactly one arbitrary caller per round; all others receive 0. See "pthread_barrier_wait() note" in the file-level docs.
Definition at line 418 of file stk_c_pthread.h.
Referenced by pthread_barrier_wait(), and stk_pthread_compile_check().
| #define PTHREAD_COND_INITIALIZER {0} |
Definition at line 350 of file stk_c_pthread.h.
| #define PTHREAD_CREATE_DETACHED (1) |
Definition at line 287 of file stk_c_pthread.h.
Referenced by pthread_attr_setdetachstate(), and pthread_create().
| #define PTHREAD_CREATE_JOINABLE (0) |
Definition at line 286 of file stk_c_pthread.h.
Referenced by pthread_attr_init(), pthread_attr_setdetachstate(), and stk_pthread_compile_check().
| #define PTHREAD_CREATE_PRIVILEGED_NP (1) |
Definition at line 294 of file stk_c_pthread.h.
Referenced by pthread_attr_setprivileged_np(), and pthread_create().
| #define PTHREAD_CREATE_USER_NP (0) |
Definition at line 293 of file stk_c_pthread.h.
Referenced by pthread_attr_init(), pthread_attr_setprivileged_np(), and stk_pthread_compile_check().
| #define PTHREAD_DESTRUCTOR_ITERATIONS (4) |
Maximum number of passes over a finishing thread's keys made while destructors keep setting new non-NULL values for their own key. See "pthread_key_t / thread-specific data" in the file-level docs.
Definition at line 452 of file stk_c_pthread.h.
Referenced by stk::pthread::RunKeyDestructors().
| #define PTHREAD_KEYS_MAX (STK_C_PTHREAD_KEYS_MAX) |
POSIX-standard name for STK_C_PTHREAD_KEYS_MAX (this file).
Definition at line 444 of file stk_c_pthread.h.
Referenced by stk_pthread_compile_check().
| #define PTHREAD_MUTEX_DEFAULT (PTHREAD_MUTEX_NORMAL) |
Definition at line 314 of file stk_c_pthread.h.
Referenced by pthread_mutex_init(), and pthread_mutexattr_init().
| #define PTHREAD_MUTEX_ERRORCHECK (1) |
Definition at line 315 of file stk_c_pthread.h.
Referenced by stk::pthread::IsValidMutexType(), stk::pthread::PreLockCheck(), pthread_cond_timedwait(), pthread_cond_wait(), and stk_pthread_compile_check().
| #define PTHREAD_MUTEX_INITIALIZER {0} |
Definition at line 330 of file stk_c_pthread.h.
| #define PTHREAD_MUTEX_NORMAL (0) |
Definition at line 313 of file stk_c_pthread.h.
Referenced by stk::pthread::IsValidMutexType().
| #define PTHREAD_MUTEX_RECURSIVE (2) |
Definition at line 316 of file stk_c_pthread.h.
Referenced by stk::pthread::IsValidMutexType(), and stk_pthread_compile_check().
| #define PTHREAD_ONCE_INIT {0} |
Definition at line 433 of file stk_c_pthread.h.
| #define PTHREAD_PROCESS_PRIVATE (0) |
Definition at line 378 of file stk_c_pthread.h.
Referenced by pthread_spin_init(), and stk_pthread_compile_check().
| #define PTHREAD_PROCESS_SHARED (1) |
Definition at line 379 of file stk_c_pthread.h.
| #define PTHREAD_RWLOCK_INITIALIZER {0} |
Definition at line 376 of file stk_c_pthread.h.
| #define STK_C_PTHREAD_DEFAULT_STACK_WORDS (1024U) |
Default per-thread stack size in stk_word_t units, used when pthread_attr_t does not specify a stack size or an external stack (default: 1024 words).
Definition at line 228 of file stk_c_pthread.h.
Referenced by stk_pthread_compile_check().
| #define STK_C_PTHREAD_KEYS_MAX (8U) |
Maximum number of concurrently-alive pthread_key_t's (default: 8).
PTHREAD_KEYS_MAX. Definition at line 244 of file stk_c_pthread.h.
Referenced by stk::pthread::IsKeyUsed(), pthread_key_create(), pthread_key_delete(), pthread_stk_ctrl_t::Reset(), and stk::pthread::RunKeyDestructors().
| #define STK_C_PTHREAD_MAX_THREADS (8U) |
Maximum number of concurrently-alive pthread_t's (default: 8).
Definition at line 216 of file stk_c_pthread.h.
Referenced by stk::pthread::AcquireThreadSlot(), stk::pthread::DequeueReap(), stk::pthread::EnqueueReap(), stk::pthread::EnsureStackPool(), and stk::pthread::STK_BLOCKPOOL_STORAGE_DECL().
| #define STK_C_PTHREAD_REAPER_STACK_WORDS (256U) |
Stack size (in stk_word_t units) for the internal reaper task that reclaims detached-thread resources (default: 256 words).
Definition at line 236 of file stk_c_pthread.h.
Referenced by stk::pthread::EnsureReaper().
| #define STK_C_PTHREAD_VERSION (0x20261004) |
Interface version.
Definition at line 202 of file stk_c_pthread.h.
| typedef struct pthread_attr_t pthread_attr_t |
Thread creation attributes.
| typedef struct pthread_barrier_t pthread_barrier_t |
A pthread barrier.
| typedef struct pthread_barrierattr_t pthread_barrierattr_t |
Barrier attributes (currently no settable properties).
| typedef struct pthread_cond_t pthread_cond_t |
A pthread condition variable.
| typedef struct pthread_condattr_t pthread_condattr_t |
Condition variable attributes (currently no settable properties).
| typedef unsigned int pthread_key_t |
A thread-specific data key.
Definition at line 439 of file stk_c_pthread.h.
| typedef struct pthread_mutex_t pthread_mutex_t |
A pthread mutex.
| typedef struct pthread_mutexattr_t pthread_mutexattr_t |
Mutex attributes.
| typedef struct pthread_once_t pthread_once_t |
A pthread_once() control object.
| typedef struct pthread_rwlock_t pthread_rwlock_t |
A pthread read-write lock.
| typedef struct pthread_rwlockattr_t pthread_rwlockattr_t |
Read-write lock attributes (currently no settable properties).
| typedef struct pthread_spinlock_t pthread_spinlock_t |
A pthread spinlock.
| typedef struct pthread_stk_ctrl_t* pthread_t |
Opaque thread handle.
Definition at line 273 of file stk_c_pthread.h.
| int pthread_attr_destroy | ( | pthread_attr_t * | attr | ) |
Destroy a thread attributes object (no-op; no owned resources).
| [in] | attr | Attributes object to destroy. |
Definition at line 777 of file stk_c_pthread.cpp.
Referenced by stk_pthread_compile_check().
| int pthread_attr_getdetachstate | ( | const pthread_attr_t * | attr, |
| int * | detachstate ) |
Get the current detach-state setting.
| [in] | attr | Attributes object to query. |
| [out] | detachstate | Receives PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. |
Definition at line 853 of file stk_c_pthread.cpp.
References pthread_attr_t::__detachstate.
| int pthread_attr_getprivileged_np | ( | const pthread_attr_t * | attr, |
| int * | mode ) |
Non-portable: get the access mode set in attr.
| [in] | attr | Attributes object to query. |
| [out] | mode | Receives PTHREAD_CREATE_USER_NP or PTHREAD_CREATE_PRIVILEGED_NP. |
Definition at line 880 of file stk_c_pthread.cpp.
References pthread_attr_t::__privileged.
Referenced by stk_pthread_compile_check().
| int pthread_attr_getstack | ( | const pthread_attr_t * | attr, |
| void ** | stackaddr, | ||
| size_t * | stacksize ) |
Get the previously-set external stack (stackaddr is NULL if none set).
| [in] | attr | Attributes object to query. |
| [out] | stackaddr | Receives the external stack address, or NULL if none was set. |
| [out] | stacksize | Receives the configured stack size in bytes (0 if no size was set). |
Definition at line 825 of file stk_c_pthread.cpp.
References pthread_attr_t::__ext_stack, and pthread_attr_t::__stack_bytes.
| int pthread_attr_getstacksize | ( | const pthread_attr_t * | attr, |
| size_t * | stacksize ) |
Get the stack size in bytes that threads created with attr will use.
If no size was set, reports STK_C_PTHREAD_DEFAULT_STACK_WORDS * sizeof(stk_word_t).
| [in] | attr | Attributes object to query. |
| [out] | stacksize | Receives the stack size in bytes (the default size if none was set). |
Definition at line 795 of file stk_c_pthread.cpp.
References pthread_attr_t::__stack_bytes, and stk::pthread::kDefaultStackBytes.
| int pthread_attr_init | ( | pthread_attr_t * | attr | ) |
Initialize a thread attributes object with default values (default stack size, no external stack, joinable).
| [out] | attr | Attributes object to initialize. |
Definition at line 761 of file stk_c_pthread.cpp.
References pthread_attr_t::__detachstate, pthread_attr_t::__ext_stack, pthread_attr_t::__privileged, pthread_attr_t::__stack_bytes, PTHREAD_CREATE_JOINABLE, and PTHREAD_CREATE_USER_NP.
Referenced by stk_pthread_compile_check().
| int pthread_attr_setdetachstate | ( | pthread_attr_t * | attr, |
| int | detachstate ) |
Set PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED.
| [in,out] | attr | Attributes object to modify. |
| [in] | detachstate | PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. |
Definition at line 839 of file stk_c_pthread.cpp.
References pthread_attr_t::__detachstate, PTHREAD_CREATE_DETACHED, and PTHREAD_CREATE_JOINABLE.
Referenced by stk_pthread_compile_check().
| int pthread_attr_setprivileged_np | ( | pthread_attr_t * | attr, |
| int | mode ) |
Non-portable: select the STK access mode of threads created with attr.
PTHREAD_CREATE_USER_NP (default) creates the thread via stk_task_create_user(); PTHREAD_CREATE_PRIVILEGED_NP via stk_task_create_privileged() (needed e.g. for direct GPIO/peripheral access on some MCUs).
| [in,out] | attr | Attributes object to modify. |
| [in] | mode | PTHREAD_CREATE_USER_NP or PTHREAD_CREATE_PRIVILEGED_NP. |
Definition at line 866 of file stk_c_pthread.cpp.
References pthread_attr_t::__privileged, PTHREAD_CREATE_PRIVILEGED_NP, and PTHREAD_CREATE_USER_NP.
Referenced by stk_pthread_compile_check().
| int pthread_attr_setstack | ( | pthread_attr_t * | attr, |
| void * | stackaddr, | ||
| size_t | stacksize ) |
Supply an external, caller-owned stack buffer for the thread.
The buffer is never freed by this shim; the caller must keep it valid for the entire lifetime of the thread.
| [in,out] | attr | Attributes object to modify. |
| [in] | stackaddr | Pointer to a stk_word_t-aligned buffer. |
| [in] | stacksize | Size of the buffer in bytes. |
Definition at line 808 of file stk_c_pthread.cpp.
References pthread_attr_t::__ext_stack, pthread_attr_t::__stack_bytes, and STK_ALIGN_MASK.
| int pthread_attr_setstacksize | ( | pthread_attr_t * | attr, |
| size_t | stacksize ) |
Set the requested stack size in bytes.
| [in,out] | attr | Attributes object to modify. |
| [in] | stacksize | Requested stack size in bytes. Must not be 0. |
Definition at line 782 of file stk_c_pthread.cpp.
References pthread_attr_t::__stack_bytes.
Referenced by stk_pthread_compile_check().
| int pthread_barrier_destroy | ( | pthread_barrier_t * | barrier | ) |
Destroy a barrier, releasing the underlying STK barrier object.
No thread may be blocked in pthread_barrier_wait() on it. After destruction it must be re-initialized with pthread_barrier_init() before further use.
| [in,out] | barrier | Barrier to destroy. |
Definition at line 1648 of file stk_c_pthread.cpp.
References pthread_barrier_t::__handle, and stk::pthread::HandleOf().
Referenced by stk_pthread_compile_check().
| int pthread_barrier_init | ( | pthread_barrier_t * | barrier, |
| const pthread_barrierattr_t * | attr, | ||
| unsigned int | count ) |
Initialize a barrier for count participating threads.
| [out] | barrier | Barrier to initialize. |
| [in] | attr | Optional, or NULL for defaults (no settable properties). |
| [in] | count | Number of threads that must call pthread_barrier_wait() before any of them is released. Must not be 0. |
Definition at line 1634 of file stk_c_pthread.cpp.
References pthread_barrier_t::__handle, pthread_barrier_t::__mem, and stk::ConstructIn().
Referenced by stk_pthread_compile_check().
| int pthread_barrier_wait | ( | pthread_barrier_t * | barrier | ) |
Block until count threads have called this function, then release them all together; the barrier resets for reuse.
| [in,out] | barrier | Barrier to wait on. |
Definition at line 1665 of file stk_c_pthread.cpp.
References pthread_barrier_t::__handle, stk::pthread::HandleOf(), and PTHREAD_BARRIER_SERIAL_THREAD.
Referenced by stk_pthread_compile_check().
| int pthread_barrierattr_destroy | ( | pthread_barrierattr_t * | attr | ) |
Destroy a barrier attributes object (no-op).
| [in] | attr | Attributes object to destroy. |
Definition at line 1629 of file stk_c_pthread.cpp.
| int pthread_barrierattr_init | ( | pthread_barrierattr_t * | attr | ) |
Initialize a barrier attributes object (no settable properties).
| [out] | attr | Attributes object to initialize. |
Definition at line 1616 of file stk_c_pthread.cpp.
References pthread_barrierattr_t::__reserved.
| int pthread_cond_broadcast | ( | pthread_cond_t * | cond | ) |
Wake all threads waiting on cond (no effect if none is waiting).
| [in,out] | cond | Condition variable to broadcast. |
Definition at line 1353 of file stk_c_pthread.cpp.
References stk::pthread::EnsureCond(), and stk::sync::ConditionVariable::NotifyAll().
Referenced by stk_pthread_compile_check().
| int pthread_cond_destroy | ( | pthread_cond_t * | cond | ) |
Destroy a condition variable, releasing the underlying STK object.
Safe on a never-used PTHREAD_COND_INITIALIZER object. No thread may be waiting on it; destroying a condition variable in use is undefined behavior.
| [in,out] | cond | Condition variable to destroy. |
Definition at line 1282 of file stk_c_pthread.cpp.
References pthread_cond_t::__handle, and stk::pthread::HandleOf().
Referenced by stk_pthread_compile_check().
| int pthread_cond_init | ( | pthread_cond_t * | cond, |
| const pthread_condattr_t * | attr ) |
Initialize a condition variable.
| [out] | cond | Condition variable to initialize. |
| [in] | attr | Optional, or NULL for defaults (no settable properties; the argument is ignored). |
Definition at line 1269 of file stk_c_pthread.cpp.
References pthread_cond_t::__handle, pthread_cond_t::__mem, and stk::ConstructIn().
Referenced by stk_pthread_compile_check().
| int pthread_cond_signal | ( | pthread_cond_t * | cond | ) |
Wake one thread waiting on cond (no effect if none is waiting).
The condition variable is created lazily if needed. Signals are not queued: a signal sent while nobody waits is lost.
| [in,out] | cond | Condition variable to signal. |
Definition at line 1340 of file stk_c_pthread.cpp.
References stk::pthread::EnsureCond(), and stk::sync::ConditionVariable::NotifyOne().
Referenced by stk_pthread_compile_check().
| int pthread_cond_timedwait | ( | pthread_cond_t * | cond, |
| pthread_mutex_t * | mutex, | ||
| const struct timespec * | abstime ) |
As pthread_cond_wait(), with an absolute deadline.
mutex is re-locked before returning in all cases, including on timeout.
| [in,out] | cond | Condition variable to wait on. |
| [in,out] | mutex | Mutex protecting the predicate; must be locked by the caller. It is released while waiting and re-locked before returning. |
| [in] | abstime | Absolute deadline on the stk_time_now_ms() timeline (not CLOCK_REALTIME); see the file-level docs. |
Definition at line 1319 of file stk_c_pthread.cpp.
References pthread_mutex_t::__handle, pthread_mutex_t::__type, stk::pthread::EnsureCond(), stk::pthread::HandleOf(), stk::pthread::IsMutexOwner(), PTHREAD_MUTEX_ERRORCHECK, stk::pthread::TimespecToRelativeTimeout(), and stk::sync::ConditionVariable::Wait().
Referenced by stk_pthread_compile_check().
| int pthread_cond_wait | ( | pthread_cond_t * | cond, |
| pthread_mutex_t * | mutex ) |
Atomically unlock mutex and wait for a signal; re-locks mutex before returning.
Waits without a timeout. As in POSIX, spurious wakeups are possible, so always re-check the predicate in a loop. mutex must be locked by the caller and must have been used or initialized before (its underlying STK mutex must exist). Must not be called from ISR context.
| [in,out] | cond | Condition variable to wait on. |
| [in,out] | mutex | Mutex protecting the predicate; must be locked by the caller. It is released while waiting and re-locked before returning. |
Definition at line 1299 of file stk_c_pthread.cpp.
References pthread_mutex_t::__handle, pthread_mutex_t::__type, stk::pthread::EnsureCond(), stk::pthread::HandleOf(), stk::pthread::IsMutexOwner(), PTHREAD_MUTEX_ERRORCHECK, and stk::sync::ConditionVariable::Wait().
Referenced by stk_pthread_compile_check().
| int pthread_condattr_destroy | ( | pthread_condattr_t * | attr | ) |
Destroy a condition variable attributes object (no-op).
| [in] | attr | Attributes object to destroy. |
Definition at line 1264 of file stk_c_pthread.cpp.
| int pthread_condattr_init | ( | pthread_condattr_t * | attr | ) |
Initialize a condition variable attributes object (no settable properties).
| [out] | attr | Attributes object to initialize. |
Definition at line 1251 of file stk_c_pthread.cpp.
References pthread_condattr_t::__reserved.
| int pthread_create | ( | pthread_t * | thread, |
| const pthread_attr_t * | attr, | ||
| void *(* | start_routine )(void *), | ||
| void * | arg ) |
Create and start a new thread.
| [out] | thread | Receives the new thread's handle on success. |
| [in] | attr | Optional attributes, or NULL for defaults. |
| [in] | start_routine | Thread entry function. |
| [in] | arg | Argument passed to start_routine. |
Definition at line 896 of file stk_c_pthread.cpp.
References pthread_attr_t::__detachstate, pthread_attr_t::__privileged, pthread_attr_t::__stack_bytes, stk::ACCESS_PRIVILEGED, stk::ACCESS_USER, stk::pthread::AcquireThreadSlot(), stk::IKernel::AddTask(), stk::pthread::AllocateStack(), pthread_stk_ctrl_t::arg, pthread_stk_ctrl_t::busy, stk::ConstructIn(), pthread_stk_ctrl_t::detached, pthread_stk_ctrl_t::done_event, pthread_stk_ctrl_t::done_event_buf, stk::pthread::PthreadTask::Initialize(), stk::pthread::kDefaultStackBytes, PTHREAD_CREATE_DETACHED, PTHREAD_CREATE_PRIVILEGED_NP, pthread_stk_ctrl_t::retval, stk::pthread::s_BoundKernel, pthread_stk_ctrl_t::stack, pthread_stk_ctrl_t::start_routine, STK_C_ASSERT, pthread_stk_ctrl_t::task, and stk::pthread::ToKernel().
Referenced by stk_pthread_compile_check().
| int pthread_detach | ( | pthread_t | thread | ) |
Mark a thread as detached.
A detached thread's resources are reclaimed automatically (by an internal reaper task) once it finishes; it must not be joined.
| [in] | thread | Thread to detach, as returned by pthread_create(). |
Definition at line 1003 of file stk_c_pthread.cpp.
References pthread_stk_ctrl_t::detached, pthread_stk_ctrl_t::joined, and stk::pthread::MaybeReap().
Referenced by stk_pthread_compile_check().
Compare two thread handles for equality.
| [in] | t1 | First thread handle. |
| [in] | t2 | Second thread handle. |
Definition at line 1078 of file stk_c_pthread.cpp.
Referenced by stk_pthread_compile_check().
| void pthread_exit | ( | void * | retval | ) |
Terminate the calling thread.
| [in] | retval | Value made available to a joiner via pthread_join(), or discarded if the thread is detached. |
Definition at line 1038 of file stk_c_pthread.cpp.
References pthread_stk_ctrl_t::adopted, stk::pthread::CurrentCtrl(), pthread_stk_ctrl_t::done_event, pthread_stk_ctrl_t::finished, stk::pthread::MaybeReap(), pthread_stk_ctrl_t::retval, stk::pthread::RunKeyDestructors(), stk::pthread::s_BoundKernel, stk::IKernel::ScheduleTaskRemoval(), stk::sync::Event::Set(), stk::Sleep(), STK_C_ASSERT, pthread_stk_ctrl_t::task, stk::pthread::ToKernel(), and stk::WAIT_INFINITE.
Referenced by stk_pthread_compile_check().
| void * pthread_getspecific | ( | pthread_key_t | key | ) |
Get the calling thread's value for key.
| [in] | key | Key to read the calling thread's value for. |
Definition at line 1794 of file stk_c_pthread.cpp.
References stk::pthread::CurrentCtrl(), stk::pthread::IsKeyUsed(), and pthread_stk_ctrl_t::tsd.
Referenced by stk_pthread_compile_check().
| int pthread_join | ( | pthread_t | thread, |
| void ** | retval ) |
Block until the given joinable thread finishes, then reclaim its resources.
| [in] | thread | Thread to join. |
| [out] | retval | Optional; receives the thread's return value / the value passed to pthread_exit(). |
Definition at line 956 of file stk_c_pthread.cpp.
References stk::pthread::CurrentCtrl(), pthread_stk_ctrl_t::detached, pthread_stk_ctrl_t::done_event, pthread_stk_ctrl_t::joined, stk::pthread::ReleaseThreadResources(), pthread_stk_ctrl_t::retval, stk::sync::Event::Wait(), and stk::pthread::WaitForTaskExit().
Referenced by stk_pthread_compile_check().
| int pthread_key_create | ( | pthread_key_t * | key, |
| void(* | destructor )(void *) ) |
Allocate a new thread-specific data key.
| [out] | key | Receives the new key on success. |
| [in] | destructor | Optional; called with a thread's non-NULL value for this key when that thread finishes. May be NULL. |
Definition at line 1728 of file stk_c_pthread.cpp.
References stk::pthread::s_Keys, and STK_C_PTHREAD_KEYS_MAX.
Referenced by stk_pthread_compile_check().
| int pthread_key_delete | ( | pthread_key_t | key | ) |
Free a thread-specific data key.
Does not run destructors and does not clear any thread's stored value for this key (matching POSIX); reusing a stale value after deletion is undefined behavior, as in real pthreads.
| [in] | key | Key to delete, as returned by pthread_key_create(). |
Definition at line 1753 of file stk_c_pthread.cpp.
References stk::pthread::s_Keys, and STK_C_PTHREAD_KEYS_MAX.
Referenced by stk_pthread_compile_check().
| int pthread_mutex_destroy | ( | pthread_mutex_t * | mutex | ) |
Destroy a mutex, releasing the underlying STK mutex object.
Safe to call on a mutex that was statically initialized with PTHREAD_MUTEX_INITIALIZER but never used (nothing to destroy). The mutex must not be locked and no thread may be blocked on it; destroying a mutex in use is undefined behavior. After destruction the object may be re-initialized with pthread_mutex_init().
| [in,out] | mutex | Mutex to destroy. |
Definition at line 1155 of file stk_c_pthread.cpp.
References pthread_mutex_t::__handle, stk::pthread::HandleOf(), and stk::sync::Mutex::~Mutex().
Referenced by stk_pthread_compile_check().
| int pthread_mutex_init | ( | pthread_mutex_t * | mutex, |
| const pthread_mutexattr_t * | attr ) |
Initialize a mutex.
| [out] | mutex | Mutex to initialize (storage is embedded in the object, nothing is allocated). |
| [in] | attr | Optional, or NULL for defaults (PTHREAD_MUTEX_DEFAULT). |
Definition at line 1136 of file stk_c_pthread.cpp.
References pthread_mutex_t::__handle, pthread_mutex_t::__mem, pthread_mutex_t::__type, pthread_mutexattr_t::__type, stk::ConstructIn(), stk::pthread::IsValidMutexType(), and PTHREAD_MUTEX_DEFAULT.
Referenced by stk_pthread_compile_check().
| int pthread_mutex_lock | ( | pthread_mutex_t * | mutex | ) |
Lock a mutex, blocking until it becomes available.
The underlying STK mutex is created lazily on first use for a mutex statically initialized with PTHREAD_MUTEX_INITIALIZER. Blocking puts the calling task to sleep so other tasks can run. For NORMAL and RECURSIVE types relocking from the owning thread succeeds and must be balanced by the same number of unlocks (the underlying STK mutex is recursive). For ERRORCHECK relocking from the owner returns EDEADLK. Must not be called from ISR context.
| [in,out] | mutex | Mutex to lock. |
Definition at line 1172 of file stk_c_pthread.cpp.
References stk::pthread::EnsureMutex(), stk::sync::Mutex::Lock(), and stk::pthread::PreLockCheck().
Referenced by stk_pthread_compile_check().
| int pthread_mutex_timedlock | ( | pthread_mutex_t * | mutex, |
| const struct timespec * | abstime ) |
Lock with an absolute deadline.
If abstime is already in the past the call degenerates into a non-blocking attempt. Timeouts are rounded to STK kernel ticks.
| [in,out] | mutex | Mutex to lock. |
| [in] | abstime | Absolute deadline on the stk_time_now_ms() timeline (not CLOCK_REALTIME); see the file-level docs. |
Definition at line 1230 of file stk_c_pthread.cpp.
References stk::pthread::EnsureMutex(), stk::pthread::PreLockCheck(), stk::sync::Mutex::TimedLock(), and stk::pthread::TimespecToRelativeTimeout().
Referenced by stk_pthread_compile_check().
| int pthread_mutex_trylock | ( | pthread_mutex_t * | mutex | ) |
Try to lock a mutex without blocking.
For NORMAL and RECURSIVE types succeeds if the caller already owns the mutex (nesting depth is incremented). For ERRORCHECK returns EBUSY.
| [in,out] | mutex | Mutex to try to lock. |
Definition at line 1190 of file stk_c_pthread.cpp.
References stk::pthread::EnsureMutex(), stk::pthread::PreLockCheck(), and stk::sync::Mutex::TryLock().
Referenced by stk_pthread_compile_check().
| int pthread_mutex_unlock | ( | pthread_mutex_t * | mutex | ) |
Unlock a mutex held by the calling thread.
Unlike pthread_mutex_lock(), never creates the underlying STK mutex: unlocking a statically initialized mutex that has never been locked is an error. As with real pthreads, unlocking a mutex the caller does not own is undefined behavior and is not detected here.
| [in,out] | mutex | Mutex to unlock; must be locked by the calling thread. |
Definition at line 1208 of file stk_c_pthread.cpp.
References pthread_mutex_t::__handle, stk::pthread::HandleOf(), stk::pthread::IsMutexOwner(), and stk::sync::Mutex::Unlock().
Referenced by stk_pthread_compile_check().
| int pthread_mutexattr_destroy | ( | pthread_mutexattr_t * | attr | ) |
Destroy a mutex attributes object (no-op; no owned resources).
| [in] | attr | Attributes object to destroy. |
Definition at line 1105 of file stk_c_pthread.cpp.
Referenced by stk_pthread_compile_check().
| int pthread_mutexattr_gettype | ( | const pthread_mutexattr_t * | attr, |
| int * | type ) |
Get the mutex type stored in attr.
| [in] | attr | Attributes object to query. |
| [out] | type | Receives the mutex type. |
Definition at line 1123 of file stk_c_pthread.cpp.
References pthread_mutexattr_t::__type.
| int pthread_mutexattr_init | ( | pthread_mutexattr_t * | attr | ) |
Initialize a mutex attributes object with default values (PTHREAD_MUTEX_DEFAULT).
| [out] | attr | Attributes object to initialize. |
Definition at line 1092 of file stk_c_pthread.cpp.
References pthread_mutexattr_t::__type, and PTHREAD_MUTEX_DEFAULT.
Referenced by stk_pthread_compile_check().
| int pthread_mutexattr_settype | ( | pthread_mutexattr_t * | attr, |
| int | type ) |
Set the mutex type.
| [in,out] | attr | Attributes object to modify. |
| [in] | type | PTHREAD_MUTEX_NORMAL / DEFAULT / RECURSIVE / ERRORCHECK. |
Definition at line 1110 of file stk_c_pthread.cpp.
References pthread_mutexattr_t::__type, and stk::pthread::IsValidMutexType().
Referenced by stk_pthread_compile_check().
| int pthread_once | ( | pthread_once_t * | once_control, |
| void(* | init_routine )(void) ) |
Call init_routine exactly once for a given once_control, no matter how many threads call pthread_once() on it concurrently.
| [in,out] | once_control | Control object, statically initialized with PTHREAD_ONCE_INIT. |
| [in] | init_routine | Function to call exactly once. Must not call pthread_once() on the same once_control. |
Definition at line 1680 of file stk_c_pthread.cpp.
References pthread_once_t::__state, stk::pthread::EnsureOnceMutex(), stk::pthread::IsMutexOwner(), stk::pthread::kOnceDone, stk::pthread::kOnceRunning, stk::pthread::LoadAcquire(), stk::sync::Mutex::Lock(), stk::pthread::StoreRelease(), and stk::sync::Mutex::Unlock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_destroy | ( | pthread_rwlock_t * | rwlock | ) |
Destroy a read-write lock, releasing the underlying STK object.
Safe on a never-used PTHREAD_RWLOCK_INITIALIZER object. The lock must not be held and no thread may be blocked on it.
| [in,out] | rwlock | Read-write lock to destroy. |
Definition at line 1401 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__handle, and stk::pthread::HandleOf().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_init | ( | pthread_rwlock_t * | rwlock, |
| const pthread_rwlockattr_t * | attr ) |
Initialize a read-write lock.
| [out] | rwlock | Read-write lock to initialize. |
| [in] | attr | Optional, or NULL for defaults (no settable properties). |
Definition at line 1387 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__handle, pthread_rwlock_t::__mem, pthread_rwlock_t::__wrlocked, and stk::ConstructIn().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_rdlock | ( | pthread_rwlock_t * | rwlock | ) |
Acquire the lock for shared reading. Blocks until available.
Blocks if a writer is currently active or writers are waiting (writer-preference policy; see RWMutex::TimedReadLock()).
| [in,out] | rwlock | Read-write lock to acquire for reading. |
Definition at line 1418 of file stk_c_pthread.cpp.
References stk::pthread::EnsureRWLock(), and stk::sync::RWMutex::ReadLock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_timedrdlock | ( | pthread_rwlock_t * | rwlock, |
| const struct timespec * | abstime ) |
Acquire the read lock with an absolute deadline.
| [in,out] | rwlock | Read-write lock to acquire for reading. |
| [in] | abstime | Absolute deadline on the stk_time_now_ms() timeline (not CLOCK_REALTIME); see the file-level docs. |
Definition at line 1443 of file stk_c_pthread.cpp.
References stk::pthread::EnsureRWLock(), stk::sync::RWMutex::TimedReadLock(), and stk::pthread::TimespecToRelativeTimeout().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_timedwrlock | ( | pthread_rwlock_t * | rwlock, |
| const struct timespec * | abstime ) |
Acquire the write lock with an absolute deadline.
| [in,out] | rwlock | Read-write lock to acquire for writing. |
| [in] | abstime | Absolute deadline on the stk_time_now_ms() timeline (not CLOCK_REALTIME); see the file-level docs. |
Definition at line 1490 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__wrlocked, stk::pthread::EnsureRWLock(), and stk::pthread::TimespecToRelativeTimeout().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_tryrdlock | ( | pthread_rwlock_t * | rwlock | ) |
Try to acquire the read lock without blocking.
| [in,out] | rwlock | Read-write lock to try to acquire for reading. |
Definition at line 1431 of file stk_c_pthread.cpp.
References stk::pthread::EnsureRWLock(), and stk::sync::RWMutex::TryReadLock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_trywrlock | ( | pthread_rwlock_t * | rwlock | ) |
Try to acquire the write lock without blocking.
| [in,out] | rwlock | Read-write lock to try to acquire for writing. |
Definition at line 1470 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__wrlocked, and stk::pthread::EnsureRWLock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_unlock | ( | pthread_rwlock_t * | rwlock | ) |
Release a read or write hold, whichever the calling thread holds.
| [in,out] | rwlock | Read-write lock to release; must be held by the calling thread (for reading or writing). |
Definition at line 1510 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__handle, pthread_rwlock_t::__wrlocked, stk::pthread::HandleOf(), and stk::sync::Mutex::Unlock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlock_wrlock | ( | pthread_rwlock_t * | rwlock | ) |
Acquire the lock for exclusive writing. Blocks until available.
Blocks until all active readers have released their locks and no other writer is active.
| [in,out] | rwlock | Read-write lock to acquire for writing. |
Definition at line 1456 of file stk_c_pthread.cpp.
References pthread_rwlock_t::__wrlocked, stk::pthread::EnsureRWLock(), and stk::sync::RWMutex::Lock().
Referenced by stk_pthread_compile_check().
| int pthread_rwlockattr_destroy | ( | pthread_rwlockattr_t * | attr | ) |
Destroy a read-write lock attributes object (no-op).
| [in] | attr | Attributes object to destroy. |
Definition at line 1382 of file stk_c_pthread.cpp.
| int pthread_rwlockattr_init | ( | pthread_rwlockattr_t * | attr | ) |
Initialize a read-write lock attributes object (no settable properties).
| [out] | attr | Attributes object to initialize. |
Definition at line 1369 of file stk_c_pthread.cpp.
References pthread_rwlockattr_t::__reserved.
| pthread_t pthread_self | ( | void | ) |
Return the calling thread's own handle.
Definition at line 1073 of file stk_c_pthread.cpp.
References stk::pthread::CurrentCtrlOrAdopt().
Referenced by stk_pthread_compile_check().
| int pthread_setspecific | ( | pthread_key_t | key, |
| const void * | value ) |
Set the calling thread's value for key.
| [in] | key | Key to set the calling thread's value for. |
| [in] | value | Value to associate with the key for the calling thread (may be NULL). |
Definition at line 1772 of file stk_c_pthread.cpp.
References stk::pthread::CurrentCtrlOrAdopt(), stk::pthread::IsKeyUsed(), and pthread_stk_ctrl_t::tsd.
Referenced by stk_pthread_compile_check().
| int pthread_spin_destroy | ( | pthread_spinlock_t * | lock | ) |
Destroy a spinlock.
The spinlock must not be held. After destruction it must be re-initialized with pthread_spin_init() before further use.
| [in,out] | lock | Spinlock to destroy. |
Definition at line 1558 of file stk_c_pthread.cpp.
References pthread_spinlock_t::__handle, and stk::pthread::HandleOf().
Referenced by stk_pthread_compile_check().
| int pthread_spin_init | ( | pthread_spinlock_t * | lock, |
| int | pshared ) |
Initialize a spinlock.
| [out] | lock | Spinlock to initialize. |
| [in] | pshared | Must be PTHREAD_PROCESS_PRIVATE. |
Definition at line 1538 of file stk_c_pthread.cpp.
References pthread_spinlock_t::__handle, pthread_spinlock_t::__mem, stk::ConstructIn(), and PTHREAD_PROCESS_PRIVATE.
Referenced by stk_pthread_compile_check().
| int pthread_spin_lock | ( | pthread_spinlock_t * | lock | ) |
Acquire the spinlock, spinning until available.
Busy-waits (the task is not put to sleep), so hold it only for very short critical sections. Not recursive: relocking from the owning thread deadlocks.
| [in,out] | lock | Spinlock to acquire. |
Definition at line 1575 of file stk_c_pthread.cpp.
References pthread_spinlock_t::__handle, stk::pthread::HandleOf(), and stk::sync::Mutex::Lock().
Referenced by stk_pthread_compile_check().
| int pthread_spin_trylock | ( | pthread_spinlock_t * | lock | ) |
Try to acquire the spinlock without blocking.
| [in,out] | lock | Spinlock to try to acquire. |
Definition at line 1588 of file stk_c_pthread.cpp.
References pthread_spinlock_t::__handle, stk::pthread::HandleOf(), and stk::sync::Mutex::TryLock().
Referenced by stk_pthread_compile_check().
| int pthread_spin_unlock | ( | pthread_spinlock_t * | lock | ) |
Release a spinlock held by the calling thread.
| [in,out] | lock | Spinlock to release; must be held by the calling thread. |
Definition at line 1600 of file stk_c_pthread.cpp.
References pthread_spinlock_t::__handle, stk::pthread::HandleOf(), and stk::sync::Mutex::Unlock().
Referenced by stk_pthread_compile_check().
| int pthread_yield | ( | void | ) |
Voluntarily give up the CPU to another ready task (cooperative yield), then resume once rescheduled.
sched_yield()), but widely available as a GNU/BSD extension under this name. Definition at line 1083 of file stk_c_pthread.cpp.
References stk::Yield().
Referenced by stk_pthread_compile_check().
| void stk_pthread_bind_kernel | ( | stk_kernel_t * | kernel | ) |
Bind the STK kernel instance that pthread_create() will add new threads to.
Must be called exactly once, before the first pthread_create() call. The kernel must already be created (stk_kernel_create()) and initialized (stk_kernel_init()); it does not need to be started yet, but in practice pthread_create() will only usefully run new threads once stk_kernel_start() has been called on it.
| [in] | kernel | Kernel handle obtained from stk_kernel_create(). Its configured type (STK_C_KERNEL_TYPE_CPU_X) must include KERNEL_DYNAMIC (threads need to be able to finish/return) and KERNEL_SYNC. |
Definition at line 749 of file stk_c_pthread.cpp.
References stk::pthread::EnsureReaper(), stk::pthread::s_BoundKernel, and STK_C_ASSERT.