進程 線程
fork pthread_create創建新的控制流
exit pthread_exit從現有的控制流中退出
waitpid pthread_join從控制流中得到退出狀態
atexit pthread_cleanup_push註冊在退出控制流時調用的函數
getpid pthread_selt獲取控制流的ID
abort pthread_cancel請求控制流的非正常退出
進程ID:pid_t; 線程ID:pthread_t
進程終止方式:進程中任一線程調用exit, _Exit或_exit
線程終止方式:線程從啓動例程中返回;被同進程中的其他線程終止;線程調用pthread_exit
pthread_t pthread_selt(void);獲取自身線程ID
int pthread_create(pthread_t* restrict tidp, const pthread_attr_t* restrict attr, void* (*start_rtn)(void*), void* restrict arg);
void pthread_exit(void* rval_ptr);
int pthread_join(pthread_t thread, void** rval_ptr);
int pthread_detach(pthread_t tid);
int pthread_attr_setdetachstate(pthread_attr_t* attr, int detachstate);修改pthread_attr_t中的detachstate線程屬性,設置爲PTHREAD_CREATE_DETACHED或PTHREAD_CREATE_JOINABLE