CS560 Midterm -- March 13, 2003. Cheat Sheet


Syntax of Relevant Pthreads / Kthreads calls

#include < pthreads.h >

int pthread_create(pthread_t *new_thread_ID,
                   pthread_attr_t *attr,
                   void * (*start_func)(void *), 
                   void *arg);
int pthread_attr_init(pthread_attr_t *attr);
int pthread_join(pthread_t thread, void **value_ptr);

int pthread_mutex_init(pthread_mutex_t *mp, pthread_mutexattr_t *attr);
int pthread_mutex_lock(pthread_mutex_t *mp);
int pthread_mutex_unlock(pthread_mutex_t *mp);

void pthread_exit(void *value_ptr);
void cv_init(kcondvar_t *cvp, char *name,  kcv_type_t  type, void *arg);
void cv_wait(kcondvar_t *cvp, kmutex_t *mp);
void cv_signal(kcondvar_t *cvp);

void *kt_self();
void *kt_fork(void (*func)(void *), void *arg);
void kt_join(void *kt);
void kt_joinall();
void kt_exit();
void kt_sleep(int secs);
void kt_yield();