POSIX Threads API

POSIX threads (pthreads) interface for creating and managing threads, mutexes, condition variables, and thread-specific data.

API entry from apis.yml

apis.yml Raw ↑
name: POSIX Threads API
description: POSIX threads (pthreads) interface for creating and managing threads, mutexes, condition
  variables, and thread-specific data.
image: https://kinlane-productions.s3.amazonaws.com/apis-json/apis-json-logo.jpg
humanURL: https://man7.org/linux/man-pages/man7/pthreads.7.html
baseURL: system://unix/pthreads
tags:
- Concurrency
- Mutexes
- Pthreads
- Synchronization
- Threads
properties:
- type: Documentation
  url: https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html
- type: APIReference
  url: https://man7.org/linux/man-pages/man7/pthreads.7.html
- type: APIReference
  url: https://man7.org/linux/man-pages/man0/pthread.h.0p.html
- type: Documentation
  url: https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_create.html
operations:
- name: pthread_create
  description: Create a new thread
  parameters:
  - thread
  - attr
  - start_routine
  - arg
  returns: 0 on success, error number on failure
- name: pthread_exit
  description: Terminate the calling thread
  parameters:
  - retval
  returns: does not return
- name: pthread_join
  description: Wait for a thread to terminate
  parameters:
  - thread
  - retval
  returns: 0 on success, error number on failure
- name: pthread_detach
  description: Detach a thread so its resources are freed on termination
  parameters:
  - thread
  returns: 0 on success, error number on failure
- name: pthread_self
  description: Obtain ID of the calling thread
  parameters: []
  returns: thread ID
- name: pthread_equal
  description: Compare two thread IDs
  parameters:
  - t1
  - t2
  returns: nonzero if equal, 0 if not equal
- name: pthread_cancel
  description: Send a cancellation request to a thread
  parameters:
  - thread
  returns: 0 on success, error number on failure
- name: pthread_mutex_init
  description: Initialize a mutex
  parameters:
  - mutex
  - attr
  returns: 0 on success, error number on failure
- name: pthread_mutex_destroy
  description: Destroy a mutex
  parameters:
  - mutex
  returns: 0 on success, error number on failure
- name: pthread_mutex_lock
  description: Lock a mutex
  parameters:
  - mutex
  returns: 0 on success, error number on failure
- name: pthread_mutex_trylock
  description: Try to lock a mutex without blocking
  parameters:
  - mutex
  returns: 0 on success, error number on failure
- name: pthread_mutex_unlock
  description: Unlock a mutex
  parameters:
  - mutex
  returns: 0 on success, error number on failure
- name: pthread_cond_init
  description: Initialize a condition variable
  parameters:
  - cond
  - attr
  returns: 0 on success, error number on failure
- name: pthread_cond_destroy
  description: Destroy a condition variable
  parameters:
  - cond
  returns: 0 on success, error number on failure
- name: pthread_cond_wait
  description: Wait on a condition variable
  parameters:
  - cond
  - mutex
  returns: 0 on success, error number on failure
- name: pthread_cond_signal
  description: Signal a condition variable waking one waiting thread
  parameters:
  - cond
  returns: 0 on success, error number on failure
- name: pthread_cond_broadcast
  description: Broadcast a condition variable waking all waiting threads
  parameters:
  - cond
  returns: 0 on success, error number on failure
- name: pthread_rwlock_init
  description: Initialize a read-write lock
  parameters:
  - rwlock
  - attr
  returns: 0 on success, error number on failure
- name: pthread_rwlock_rdlock
  description: Lock a read-write lock for reading
  parameters:
  - rwlock
  returns: 0 on success, error number on failure
- name: pthread_rwlock_wrlock
  description: Lock a read-write lock for writing
  parameters:
  - rwlock
  returns: 0 on success, error number on failure
- name: pthread_rwlock_unlock
  description: Unlock a read-write lock
  parameters:
  - rwlock
  returns: 0 on success, error number on failure
- name: pthread_key_create
  description: Create a thread-specific data key
  parameters:
  - key
  - destructor
  returns: 0 on success, error number on failure
- name: pthread_setspecific
  description: Set thread-specific data value
  parameters:
  - key
  - value
  returns: 0 on success, error number on failure
- name: pthread_getspecific
  description: Get thread-specific data value
  parameters:
  - key
  returns: pointer to thread-specific data, NULL if no value set
- name: pthread_once
  description: Ensure initialization routine is called exactly once
  parameters:
  - once_control
  - init_routine
  returns: 0 on success, error number on failure
- name: pthread_attr_init
  description: Initialize thread attributes object
  parameters:
  - attr
  returns: 0 on success, error number on failure
- name: pthread_attr_destroy
  description: Destroy thread attributes object
  parameters:
  - attr
  returns: 0 on success, error number on failure