14 #include <core/page.h> 29 #define PTHREAD_STACK_MIN (PAGE_SIZE) 33 #define PTHREAD_GUARD_MIN (PAGE_SIZE) 37 #define PTHREAD_GUARD_MAX (PAGE_SIZE << 2) 41 #define MUTEX_STATE_UNLOCKED 0 44 #define MUTEX_STATE_LOCKED 1 48 #define PTHREAD_MUTEX_INITIALIZER \ 49 { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_DEFAULT, 0, 0 } 53 #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ 54 { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_ERRORCHECK, 0, 0 } 58 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ 59 { { MUTEX_STATE_UNLOCKED }, PTHREAD_MUTEX_RECURSIVE, 0, 0 } 91 atomic_t already_executed;
96 #define PTHREAD_ONCE_INIT { ATOMIC_INITIALIZER } 102 unsigned int stacksize;
103 unsigned int guardsize;
120 pthread_t caller_thread;
143 #define PTHREAD_COND_INITIALIZER { ATOMIC_INITIALIZER } 285 void *(*start_routine) (
void *),
327 DSO_EXPORT
int pthread_join(pthread_t thread,
void **retval);
368 void (*init_routine)(
void));
817 const pthread_mutexattr_t *attr);
1034 const struct timespec *timeout);
1065 DSO_EXPORT
int pthread_kill(pthread_t thread,
int sig);
1136 #define pthread_sigmask(how, set, oldset) sigprocmask(how, set, oldset) int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set the detach state attribute.
int pthread_cond_signal(pthread_cond_t *cond)
Unblock at least one of the threads that are blocked on the specified condition variable cond (if any...
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Release lock on currently locked mutex.
int pthread_detach(pthread_t thread)
Detach a thread.
pthread_t pthread_self(void)
Obtain ID of the calling thread.
uintptr_t pthread_t
Definition: pthread.h:66
Definition: pthread.h:136
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
The pthread_attr_setstacksize() function sets size of stack.
struct pthread_impl pthread_impl_t
Definition: pthread.h:62
int pthread_cond_broadcast(pthread_cond_t *cond)
Wake up all threads locked by conditional variable cond.
int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize)
The pthread_attr_setstack() function sets stack address and size.
Definition: pthread.h:130
Definition: pthread.h:111
uint32_t pthread_mutexattr_t
Definition: pthread.h:70
int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
If any thread in a process with a once_control parameter makes a call to pthread_once(), the first call will summon the init_routine(), but subsequent calls will not. The once_control parameter determines whether the associated initialization routine has been called. The init_routine() is complete upon return of pthread_once().
int pthread_kill(pthread_t thread, int sig)
Send signal to specified thread.
int pthread_key_delete(pthread_key_t key)
Delete data key and destructor associated with key. After key deletion there is no destructor will be...
void * pthread_getspecific(pthread_key_t key)
Return the value currently bound to the specified key on behalf of the calling thread.
int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize)
The pthread_attr_getstack() function gets stack address and size.
int pthread_mutex_trylock(pthread_mutex_t *mutex)
Lock mutex or fail if mutex is already locked.
int pthread_attr_init(pthread_attr_t *attr)
The pthread_attr_init() function initialize attribute struct.
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get the detach state attribute.
int pthread_condattr_destroy(pthread_condattr_t *attr)
Destroy conditional variable attributes.
Definition: pthread.h:100
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize mutex object mutex with attributes given by attr parameter. If attr parameter is NULL then...
int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
The pthread_attr_getguardsize() function gets size of guard.
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy attributes object and make all attribute values are uninitialized.
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy mutex object and make all associated data are uninitialized.
int pthread_attr_destroy(pthread_attr_t *attr)
The pthread_attr_destroy() function destroy attribute struct.
int pthread_equal(pthread_t t1, pthread_t t2)
Compare thread IDs.
Definition: pthread.h:110
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
The pthread_create() function starts a new thread in the calling process. The new thread starts execu...
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
The pthread_attr_setguardsize() function sets size of guard.
_noreturn_ void pthread_exit(void *retval)
Terminate calling thread.
int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr)
Get attributes of created thread.
int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
The pthread_attr_setstackaddr() function gets stack address.
int pthread_setspecific(pthread_key_t key, const void *value)
Associate a thread-specific value with a key obtained via a previous call to pthread_key_create().
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize mutex attributes object and initialize attributes with default values. ...
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize conditional variable object cond with attributes given by attr parameter.
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set mutex type attribute associated with attr parameter.
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_bro...
int pthread_key_create(pthread_key_t *key, void(*destructor)(void *))
Create data key for data manipulation functions (pthread_getspecific(), pthread_setspecific()). Multiple threads can call data manipulation functions with the same key. In this case all threads will have separate data.
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock mutex or wait while another thread is unlock currently locked mutex.
Definition: pthread.h:116
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy conditional variable object and make it unitialized.
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
Get mutex type attribute associated with attr parameter.
int pthread_condattr_init(pthread_condattr_t *attr)
Initialize conditional variable attributes with default values.
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *timeout)
Block on condition variable cond, while another thread will unblock this variable by pthread_cond_bro...
int pthread_join(pthread_t thread, void **retval)
Wait for the thread specified by thread to terminate. If that thread has already terminated, then returns immediately. The thread specified by thread must be joinable.
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
The pthread_attr_getstacksize() function gets size of stack.
unsigned pthread_key_t
Definition: pthread.h:147
int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
The pthread_attr_getstackaddr() function gets stack address.