| | |
Summary: 26
Interlude: Thread API
This chapter briefly covers the main portions of the thread API.
Each part will be explained further in the subsequent chapters,
as we show how to use the API. More details can be found in
various books and online sources [B97,B+96,K+96]. We should
note that the subsequent chapters introduce the concepts of locks
and condition variables more slowly, with many examples; this
chapter is thus better used as a reference.
26.1 Thread Creation
The first thing you have to be able to do to write a multi-
threaded program is to create new threads, and thus some kind
of thread creation interface must exist. In POSIX, it is easy:
#include
int
pthread_create(pthread_t * restrict thread,
const pthread_attr_t * restrict attr,
void * (*start_routine)(void*),
void * restrict arg);
Now, this declaration might look a little complex (particu-
|