Multi-Core Programming: Increasing Performance through Software Multithreading

POSIX threads, or Pthreads, is a portable threading library designed with the intent of providing a consistent programming interface across multiple operating system platforms. Pthreads is now the standard threading interface for Linux and is also widely used on most UNIX platforms. An open-source version for Windows, called pthreads-win32, is available as well. For more information on pthreads-win32, refer to References. If you want to work in C and need a portable threading API that provides more direct control than OpenMP, pthreads is a good choice.
Most core Pthreads functions focus on thread creation and destruction, synchronization, plus a few miscellaneous functions. Capabilities like thread priorities are not a part of the core pthreads library, but instead are a part of the optional capabilities that are vendor specific.
The POSIX threads call to create a thread is pthread_create():
pthread_create ( &a_thread, // thread ID goes here NULL, // thread attributes (NULL = none) PrintThreads, // function name (void *) msg ); // parameter
As in Windows, the third parameter represents a pointer to the function called by the launched thread, while the fourth parameter is a pointer to a void, which is used to pass arguments to the called function.
Listing 5.11 illustrates the usage of pthread_create()