UP | HOME

Date: <2024-10-23 Wed>

Multithreading

Table of Contents

1. Pthreads

  • pthreads (aka POSIX Threads) is an API defined in a POSIX standard (POSIX.1c 1995). It is independent of programming languages and POSIX compliant operating system provide shared library to use pthreads.

    • has ~100 functions (all with `pthread_` prefix)
      • thread management
      • condition variables
      • mutexes
      • synchronization (barriers)
      • spinlocks
    • semaphores are not included. It is available in different standard (POSIX.1b 1993).

    In Linux, the modern pthreads implementation is call NPTL (Native POSIX Threads Library) [See man pthreads 7. Older implementation was called LinuxThreads]. NPTL uses `clone` syscall for thread creation, and `futex` syscall for synchronization primitives (mutexes, thread joining, and so on).

    Is an N:1 POSIX Threads implemenation allowed?

Recommended study material for pthreads: https://hpc-tutorials.llnl.gov/posix/

2. Atomics


You can send your feedback, queries here