SLIDE 12 Pthread Example – API Calls
p
t h r e a d _ a t t r _ i n i t – i n i t i a l i z e t h e t h r e a d a t t r i b u t e s
j e c t
int pthread_attr_init(pthread_attr_t *attr); d
e fj n e s t h e a t t r i b u t e s
t h e t h r e a d c r e a t e d
p
t h r e a d _ c r e a t e – c r e a t e a n e w t h r e a d
int pthread_create(pthread_t *restrict thread, const
pthread_attr_t *restrict attr, void *(*start_routine)(void*), void *restrict arg);
upon success, a new thread id is returned in thread
pthread_join – wait for thread to exit
int pthread_join(pthread_t thread, void **value_ptr); calling process blocks until thread exits
pthread_exit – terminate the calling thread
void pthread_exit(void *value_ptr); make return value available to the joining thread