So, by now, we know how to create an application process with a few threads executing within it. We will repeat a code snippet from our very first demo program, ch14/pthreads1.c, as follows:
#include <pthread.h>#define NTHREADS 3[...]int main(void){ [...] for (i = 0; i < NTHREADS; i++) { ret = pthread_create(&tid, NULL, worker, (void *)i); if (ret) FATAL("pthread_create() failed! [%d]\n", ret); }[...]
Clearly, the process—well, we really mean the main thread of the process (or application)—goes in a loop, and each loop iteration creates a thread. So, when it's done, we will have three threads in addition to the main thread, which is a total of four threads, alive in the process.
This is obvious. The point here ...