1. Basic Concepts
A UNIX process can be understood as a thread plus an address space, a file descriptor, and other data.
Async shows that things happen independently of each other, unless there is an imposed dependency.
Concurrency refers to the fact that it's possible that things happen at the same time.
Parallelism refers to simultaneous execution of concurrent sequences.
Thread safety refers to the ability of code to be called by multiple threads without catastrophic consequences.
2. Shared data--synchronization object--mutex--relationship of conditional variables
The basic Pthread synchronization model uses mutexes to protect shared data and use conditional variables to communicate. A mutex allows a thread to lock it when it accesses shared data, allowing a thread to wait for the shared data to reach a desired state.
mutexes prevent unexpected collisions between threads.
The condition variable lets the thread wait to know that it can execute safely.
Both mutex and condition variables are used to synchronize inter-thread operations.
3. Common structure
Three basic elements of a threading system: Execution Environment, scheduling, synchronizing pthread_t thread identifiers
pthread_mutex_t Mutex Amount
pthread_code_t Condition variables
pthread_key_t thread private rights to hold access keys
pthread_attr_t Thread Property Object
pthread_condattr_t Condition Variable Property Object
4. Pthread Features
The errno variable is not set when the Pthread function is wrong.
There is no function in pthread that wants to perror the error message in the given format, it uses the Strerror function to get a description of the error code and then print it to stderr
POSIX thread Overview