pthread_t
pthread_equal
pthread_self
int pthread_create(pthread_t *tidp, const pthred_attr_t *attr,
void *(*start_rtn)(void *), void *arg)
thread退出:
1 start routine return
2 另外一个线程终结cancel. int pthread_cancel( pthread_t tid);
doestn't wait, merely make the request(async)
thread_cleanup handlers
pthread_cleanup_push( void (*rtn)(void *),void *arg)
pthread_cleanup_pop( int execute)
3 pthread_exit
void pthread_eixt( void *rval_ptr)
会被另外的线程
int pthread_join( pthread_t thread, void **rval_prt)
1 包含start routine返回的返回码
2 PTHREAD_CANCELED
3
pthread_detach for a detached thread results in undefined behavior
1 Thread limits
sysconf
12.3 Thread Attributes
pthread_attr_init( pthread_attr_t *attr)
pthread_attr_destroy( pthread_attr_t *attr)
detachstate
pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate)
pthread_attr_setdetachstate( pthread_attr_t *attr,int detachstate)
PTHREAD_CREATE_JOINABLE/PTHREAD_CREATE_DETACHED
stacksize
pthread_attr_getstack( pthread_attr_t *attr, void **stackaddr, size_t stacksize)
pthread_attr_setstack( pthread_attr_t *attr, void *stackaddr,size_t stacksize)
pthread_attr_getstacksize( pthread_attr_t *attr, size_t *stacksize)
pthread_attr_setstacksize( pthread_attr_t *attr,size_t *stacksize)
guardsize
pthread_attr_getguardsize( pthread_attr_t *attr, size_t *guardsize)
pthread_attr_setguardsize( pthread_attr_t *attr,size_t guardsize)
12.4.1 mutex attributes
pthread_mutexattr_init( pthread_muteattr_t *attr)
pthread_mutexattr_destroy( pthread_mutexattr_t *attr)
pthread_mutexattr_getpshared( pthread_mutexattr_t *attr, int *pshared);
pthread_mutexattr_setpshared( pthread_mutexattr_t *attr,int pshared)
pthread_mutexattr_getrobust( pthread_mutexattr_t *attr, int *robust)
pthread_mutexattr_setrobust(pthread_mutexattr_t *attr,int robust)
pthread_mutexattr_gettype( pthread_mutexattr_t *attr,int *type)
pthread_mutexattr_settype( pthread_mutexattr_t *attr, int type)
12.4.2 Reader-Write Lock Attributes
pthread_rwlockattr_init( pthread_rwlockattr_t *attr)
pthread_rwlockattr_destroy( pthread_rwlockattr_t *attr)
pthread_rwlockattr_getpshared( pthread_rwlockattr_t *attr,int *pshared)
pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,int pshared)
12.4.3 condition variable attributes
process-shared/ clock
12.4.4 Barrier Attributes
process-shared
12.6 Thread-Specific Data(thread-private data)
1 key
pthread_key_create( pthread_key_t *keyp, void (*destructor)(void *))
2 alloc memory for thread-specific
pthread_setspecific(pthread_key_t key, const void *value)
void *pthread_getspecific( pthread_key_t key);
12.8
Threads and Signal
pthread_sigmask( int how, sigset_t *set, sigset *oset);