This preview shows page 1. Sign up to view the full content.
Unformatted text preview: d the entire process with a return value of thread return. 568
#include <pthread.h> CHAPTER 11. CONCURRENT PROGRAMMING WITH THREADS int pthread exit(void *thread return);
returns: 0 if OK, non-zero on error ¯ ¯ Some peer thread calls the Unix exit function, which terminates the process and all threads associated with the process. Another peer thread terminates the current thread by calling the pthread cancel function with the ID of the current thread. #include <pthread.h> int pthread cancel(pthread t tid);
returns: 0 if OK, non-zero on error 11.2.3 Reaping Terminated Threads
Threads wait for other threads to terminate by calling the pthread join function.
#include <pthread.h> int pthread join(pthread t tid, void **thread return);
returns: 0 if OK, non-zero on error The pthread join function blocks until thread tid terminates, assigns the (void *) pointer returned by the thread routine to the location pointed to by thread return, and then reaps any memory resources held by the terminated thread. Notice that, unl...
View Full Document
- Spring '10
- The American