Introduction to Programming Threads
Basic Thread Routines
int pthread_create(pthread_t * thread,
const pthread_attr_t * attr,
void * (*start_routine)(void *),
- Analogous to a combined fork and exec routine
- Returns a thread id in thread .
- When attr is NULL the default thread attributes are used.
void pthread_exit(void * return_value);
- Analogous to exit
- The exit routine kills all threads and exits the process
- If the currecnt thread is the last thread then the process terminates
- Returning from the start_routine is equivalent to calling
- Returning from the inital thread main is the equivalent to
Detach and Join
int pthread_detach(pthread_t thread);
int pthread_join(pthread_t thread, void ** status);
- Analogous to wait
- Must specify thread. There is no wait any.
- Current thread blocks until thread terminates
- The return value of thread is returned in status
- All threads must be detached or joined with.
Self and Equal
int pthread_equal(pthread_1 t1, pthread_t t2);
Chris Provenzano (email@example.com)