Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
#include <kernel.h>
#include <wait_q.h>
#include <posix/time.h>
#include <posix/unistd.h>
#include "posix_types.h"
#include "posix_sched.h"
#include <posix/pthread_key.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | posix_thread |
Macros | |
#define | PTHREAD_CREATE_JOINABLE PTHREAD_JOINABLE |
#define | PTHREAD_CREATE_DETACHED PTHREAD_DETACHED |
#define | PTHREAD_CANCEL_ENABLE (0U << _PTHREAD_CANCEL_POS) |
#define | PTHREAD_CANCEL_DISABLE BIT(_PTHREAD_CANCEL_POS) |
#define | PTHREAD_ONCE_INIT 1 |
#define | PTHREAD_COND_DEFINE(name) |
Declare a pthread condition variable. More... | |
#define | PTHREAD_MUTEX_DEFINE(name) |
Declare a pthread mutex. More... | |
#define | PTHREAD_MUTEX_NORMAL 0 |
#define | PTHREAD_MUTEX_RECURSIVE 1 |
#define | PTHREAD_MUTEX_ERRORCHECK 2 |
#define | PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL |
#define | PTHREAD_PRIO_NONE 0 |
#define | PTHREAD_BARRIER_DEFINE(name, count) |
Declare a pthread barrier. More... | |
#define | PTHREAD_BARRIER_SERIAL_THREAD 1 |
Enumerations | |
enum | pthread_state { PTHREAD_TERMINATED = 0 , PTHREAD_JOINABLE , PTHREAD_DETACHED , PTHREAD_EXITED } |
Functions | |
static int | pthread_cond_init (pthread_cond_t *cv, const pthread_condattr_t *att) |
POSIX threading compatibility API. More... | |
static int | pthread_cond_destroy (pthread_cond_t *cv) |
POSIX threading compatibility API. More... | |
int | pthread_cond_signal (pthread_cond_t *cv) |
POSIX threading compatibility API. More... | |
int | pthread_cond_broadcast (pthread_cond_t *cv) |
POSIX threading compatibility API. More... | |
int | pthread_cond_wait (pthread_cond_t *cv, pthread_mutex_t *mut) |
POSIX threading compatibility API. More... | |
int | pthread_cond_timedwait (pthread_cond_t *cv, pthread_mutex_t *mut, const struct timespec *abstime) |
POSIX threading compatibility API. More... | |
static int | pthread_condattr_init (pthread_condattr_t *att) |
POSIX threading compatibility API. More... | |
static int | pthread_condattr_destroy (pthread_condattr_t *att) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_destroy (pthread_mutex_t *m) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_lock (pthread_mutex_t *m) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_unlock (pthread_mutex_t *m) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_timedlock (pthread_mutex_t *m, const struct timespec *abstime) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_trylock (pthread_mutex_t *m) |
POSIX threading compatibility API. More... | |
int | pthread_mutex_init (pthread_mutex_t *m, const pthread_mutexattr_t *att) |
POSIX threading compatibility API. More... | |
int | pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int protocol) |
POSIX threading compatibility API. More... | |
int | pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type) |
POSIX threading compatibility API. More... | |
int | pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr, int *protocol) |
POSIX threading compatibility API. More... | |
int | pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type) |
POSIX threading compatibility API. More... | |
static int | pthread_mutexattr_init (pthread_mutexattr_t *m) |
POSIX threading compatibility API. More... | |
static int | pthread_mutexattr_destroy (pthread_mutexattr_t *m) |
POSIX threading compatibility API. More... | |
int | pthread_barrier_wait (pthread_barrier_t *b) |
POSIX threading compatibility API. More... | |
static int | pthread_barrier_init (pthread_barrier_t *b, const pthread_barrierattr_t *attr, unsigned int count) |
POSIX threading compatibility API. More... | |
static int | pthread_barrier_destroy (pthread_barrier_t *b) |
POSIX threading compatibility API. More... | |
static int | pthread_barrierattr_init (pthread_barrierattr_t *b) |
POSIX threading compatibility API. More... | |
static int | pthread_barrierattr_destroy (pthread_barrierattr_t *b) |
POSIX threading compatibility API. More... | |
static pthread_t | pthread_self (void) |
Obtain ID of the calling thread. More... | |
static int | pthread_equal (pthread_t pt1, pthread_t pt2) |
Compare thread IDs. More... | |
static int | pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr) |
Destroy the read-write lock attributes object. More... | |
static int | pthread_rwlockattr_init (pthread_rwlockattr_t *attr) |
initialize the read-write lock attributes object. More... | |
int | pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize) |
int | pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) |
int | pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) |
int | pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) |
int | pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) |
int | pthread_attr_init (pthread_attr_t *attr) |
int | pthread_attr_destroy (pthread_attr_t *attr) |
int | pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *schedparam) |
int | pthread_getschedparam (pthread_t pthread, int *policy, struct sched_param *param) |
int | pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) |
int | pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize) |
int | pthread_once (pthread_once_t *once, void(*initFunc)(void)) |
void | pthread_exit (void *retval) |
int | pthread_join (pthread_t thread, void **status) |
int | pthread_cancel (pthread_t pthread) |
int | pthread_detach (pthread_t thread) |
int | pthread_create (pthread_t *newthread, const pthread_attr_t *attr, void *(*threadroutine)(void *), void *arg) |
int | pthread_setcancelstate (int state, int *oldstate) |
int | pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *schedparam) |
int | pthread_setschedparam (pthread_t pthread, int policy, const struct sched_param *param) |
int | pthread_rwlock_destroy (pthread_rwlock_t *rwlock) |
int | pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) |
int | pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) |
int | pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock, const struct timespec *abstime) |
int | pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, const struct timespec *abstime) |
int | pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) |
int | pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) |
int | pthread_rwlock_unlock (pthread_rwlock_t *rwlock) |
int | pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) |
int | pthread_key_create (pthread_key_t *key, void(*destructor)(void *)) |
int | pthread_key_delete (pthread_key_t key) |
int | pthread_setspecific (pthread_key_t key, const void *value) |
void * | pthread_getspecific (pthread_key_t key) |
int | pthread_setname_np (pthread_t thread, const char *name) |
Set name of POSIX thread. More... | |
int | pthread_getname_np (pthread_t thread, char *name, size_t len) |
Get name of POSIX thread and store in name buffer that is of size len. More... | |
#define PTHREAD_BARRIER_DEFINE | ( | name, | |
count | |||
) |
Declare a pthread barrier.
Declaration API for a pthread barrier. This is not a POSIX API, it's provided to better conform with Zephyr's allocation strategies for kernel objects.
name | Symbol name of the barrier |
count | Thread count, same as the "count" argument to pthread_barrier_init() |
#define PTHREAD_BARRIER_SERIAL_THREAD 1 |
#define PTHREAD_CANCEL_DISABLE BIT(_PTHREAD_CANCEL_POS) |
#define PTHREAD_CANCEL_ENABLE (0U << _PTHREAD_CANCEL_POS) |
#define PTHREAD_COND_DEFINE | ( | name | ) |
Declare a pthread condition variable.
Declaration API for a pthread condition variable. This is not a POSIX API, it's provided to better conform with Zephyr's allocation strategies for kernel objects.
name | Symbol name of the condition variable |
#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED |
#define PTHREAD_CREATE_JOINABLE PTHREAD_JOINABLE |
#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL |
#define PTHREAD_MUTEX_DEFINE | ( | name | ) |
Declare a pthread mutex.
Declaration API for a pthread mutex. This is not a POSIX API, it's provided to better conform with Zephyr's allocation strategies for kernel objects.
name | Symbol name of the mutex |
#define PTHREAD_MUTEX_ERRORCHECK 2 |
#define PTHREAD_MUTEX_NORMAL 0 |
#define PTHREAD_MUTEX_RECURSIVE 1 |
#define PTHREAD_ONCE_INIT 1 |
#define PTHREAD_PRIO_NONE 0 |
enum pthread_state |
int pthread_attr_destroy | ( | pthread_attr_t * | attr | ) |
int pthread_attr_getdetachstate | ( | const pthread_attr_t * | attr, |
int * | detachstate | ||
) |
int pthread_attr_getschedparam | ( | const pthread_attr_t * | attr, |
struct sched_param * | schedparam | ||
) |
int pthread_attr_getschedpolicy | ( | const pthread_attr_t * | attr, |
int * | policy | ||
) |
int pthread_attr_getstack | ( | const pthread_attr_t * | attr, |
void ** | stackaddr, | ||
size_t * | stacksize | ||
) |
int pthread_attr_getstacksize | ( | const pthread_attr_t * | attr, |
size_t * | stacksize | ||
) |
int pthread_attr_init | ( | pthread_attr_t * | attr | ) |
int pthread_attr_setdetachstate | ( | pthread_attr_t * | attr, |
int | detachstate | ||
) |
int pthread_attr_setschedparam | ( | pthread_attr_t * | attr, |
const struct sched_param * | schedparam | ||
) |
int pthread_attr_setschedpolicy | ( | pthread_attr_t * | attr, |
int | policy | ||
) |
int pthread_attr_setstack | ( | pthread_attr_t * | attr, |
void * | stackaddr, | ||
size_t | stacksize | ||
) |
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_barrier_wait | ( | pthread_barrier_t * | b | ) |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
Note that pthread attribute structs are currently noops in Zephyr.
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
Note that pthread attribute structs are currently noops in Zephyr.
int pthread_cancel | ( | pthread_t | pthread | ) |
int pthread_cond_broadcast | ( | pthread_cond_t * | cv | ) |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_cond_signal | ( | pthread_cond_t * | cv | ) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_cond_timedwait | ( | pthread_cond_t * | cv, |
pthread_mutex_t * | mut, | ||
const struct timespec * | abstime | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_cond_wait | ( | pthread_cond_t * | cv, |
pthread_mutex_t * | mut | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
Note that pthread attribute structs are currently noops in Zephyr.
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1.
Note that pthread attribute structs are currently noops in Zephyr.
int pthread_create | ( | pthread_t * | newthread, |
const pthread_attr_t * | attr, | ||
void *(*)(void *) | threadroutine, | ||
void * | arg | ||
) |
int pthread_detach | ( | pthread_t | thread | ) |
|
inlinestatic |
Compare thread IDs.
See IEEE 1003.1
int pthread_getname_np | ( | pthread_t | thread, |
char * | name, | ||
size_t | len | ||
) |
Get name of POSIX thread and store in name buffer that is of size len.
Non-portable, extension function that conforms with most other definitions of this function.
thread | POSIX thread to obtain name information |
name | Destination buffer |
len | Destination buffer size |
0 | Success |
ESRCH | Thread does not exist |
EINVAL | Name buffer is NULL |
Negative | value if kernel function error |
int pthread_getschedparam | ( | pthread_t | pthread, |
int * | policy, | ||
struct sched_param * | param | ||
) |
void * pthread_getspecific | ( | pthread_key_t | key | ) |
int pthread_join | ( | pthread_t | thread, |
void ** | status | ||
) |
int pthread_key_delete | ( | pthread_key_t | key | ) |
int pthread_mutex_destroy | ( | pthread_mutex_t * | m | ) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutex_init | ( | pthread_mutex_t * | m, |
const pthread_mutexattr_t * | att | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutex_lock | ( | pthread_mutex_t * | m | ) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutex_timedlock | ( | pthread_mutex_t * | m, |
const struct timespec * | abstime | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutex_trylock | ( | pthread_mutex_t * | m | ) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutex_unlock | ( | pthread_mutex_t * | m | ) |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
Note that pthread attribute structs are currently noops in Zephyr.
int pthread_mutexattr_getprotocol | ( | const pthread_mutexattr_t * | attr, |
int * | protocol | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutexattr_gettype | ( | const pthread_mutexattr_t * | attr, |
int * | type | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
|
inlinestatic |
POSIX threading compatibility API.
See IEEE 1003.1
Note that pthread attribute structs are currently noops in Zephyr.
int pthread_mutexattr_setprotocol | ( | pthread_mutexattr_t * | attr, |
int | protocol | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_mutexattr_settype | ( | pthread_mutexattr_t * | attr, |
int | type | ||
) |
POSIX threading compatibility API.
See IEEE 1003.1
int pthread_rwlock_destroy | ( | pthread_rwlock_t * | rwlock | ) |
int pthread_rwlock_init | ( | pthread_rwlock_t * | rwlock, |
const pthread_rwlockattr_t * | attr | ||
) |
int pthread_rwlock_rdlock | ( | pthread_rwlock_t * | rwlock | ) |
int pthread_rwlock_timedrdlock | ( | pthread_rwlock_t * | rwlock, |
const struct timespec * | abstime | ||
) |
int pthread_rwlock_timedwrlock | ( | pthread_rwlock_t * | rwlock, |
const struct timespec * | abstime | ||
) |
int pthread_rwlock_tryrdlock | ( | pthread_rwlock_t * | rwlock | ) |
int pthread_rwlock_trywrlock | ( | pthread_rwlock_t * | rwlock | ) |
int pthread_rwlock_unlock | ( | pthread_rwlock_t * | rwlock | ) |
int pthread_rwlock_wrlock | ( | pthread_rwlock_t * | rwlock | ) |
|
inlinestatic |
Destroy the read-write lock attributes object.
See IEEE 1003.1
|
inlinestatic |
initialize the read-write lock attributes object.
See IEEE 1003.1
|
inlinestatic |
Obtain ID of the calling thread.
The results of calling this API from threads not created with pthread_create() are undefined.
See IEEE 1003.1
int pthread_setcancelstate | ( | int | state, |
int * | oldstate | ||
) |
int pthread_setname_np | ( | pthread_t | thread, |
const char * | name | ||
) |
Set name of POSIX thread.
Non-portable, extension function that conforms with most other definitions of this function.
thread | POSIX thread to set name |
name | Name string |
0 | Success |
ESRCH | Thread does not exist |
EINVAL | Name buffer is NULL |
Negative | value if kernel function error |
int pthread_setschedparam | ( | pthread_t | pthread, |
int | policy, | ||
const struct sched_param * | param | ||
) |
int pthread_setspecific | ( | pthread_key_t | key, |
const void * | value | ||
) |