June 2017
Intermediate to advanced
478 pages
13h 14m
English
The function to create a thread is pthread_create(3):
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
It creates a new thread of execution that begins in the function start_routine and places a descriptor in the pthread_t pointed to by thread. It inherits the scheduling parameters of the calling thread, but these can be overridden by passing a pointer to the thread attributes in attr. The thread will begin to execute immediately.
pthread_t is the main way to refer to the thread within the program, but the thread can also be seen from outside using a command such as ps -eLf:
UID PID PPID LWP C NLWP STIME TTY TIME CMD...chris 6072 5648 6072 0 3 21:18 pts/0 ...
Read now
Unlock full access