pthread | It creates a new thread and makes it executable. |
thread | It is an unique identifier for the new thread returned by the subroutine. |
attr | It is an attribute object used to set thread attributes. |
start_routine | It defines the C++ routine that the thread will execute once it is created. |
arg | It defines a single argument that may be passed to start_routine. |
Pthread API | Description |
---|---|
Thread Management | In thread management, routine directly works (such as creating, detaching, joining etc.) on threads. It includes function to set/query thread attributes such as joinable, scheduling etc. |
Mutex | Routine deals with synchronization is called a Mutex. It is an abbreviation for “mutual exclusion”. The functions of mutex are provide for creating, destroying, locking and unlocking mutexes. It is used to protect shared data from simultaneous access. It can be locked and unlocked. Once it is locked, current thread owns mutex until it is not unlocked. It means that no other thread can execute any instructions from the block of code surrounded by mutex until thread that owns mutex unlocks it. The <mutex> header file is used if you want to use mutex. |
Condition Variables | In condition variables, routine address communication is done between threads that share a mutex. It is based upon program specified conditions. It includes create, destroy, wait and signal based upon specified variable values. |
Synchronization | In synchronization, routine manages read/write locks and barriers. |