Thread creation
pthread_create()
what does pthread_join() do?
waits for a thread to complete
what is the type of thread?
pthread_t
what are the function for locks?
int pthread_mutex_lock(pthread_mutex_t *mutex) int pthread_mutex_unlock(pthread_mutex_t *mutex)
init
pthread_mutex_t = PTHREAD_MUTEX_INITIALIZER;
or
int rc = pthread_mutex_init(&lock, NULL);
rc == 0 if success
what are timedlocks and trylocks?
int pthread_mutex_trylock(pthread_mutex_t *mutex); trylock returns failure if lock is already held
int pthread_mutex_timedlock(pthread_mutex_t *mutex, time); after acquiring a lock. returns after a timeout or finish acquiring a lock. whichever comes first.
what are the functions for Condition Variables?
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); int pthread_cond_signal(pthread_cond_t *cond); note: wait takes cv and mutex. singal only takes cv.
pthread_cond_t cond = PTHREAD_COND_INITIALIZER