Skip to content
systemcoding.dev

Tag

pthreads

7 posts

Flat illustration of parallel threads meeting at a mutex, with the C, C++ and Erlang logos.
Concurrency

Wait for Conditions with pthread_cond_wait

Make a C thread sleep until another signals that work is ready with pthread_cond_wait, pthread_cond_signal and a predicate loop on Linux with glibc 2.41.

8 min read
Flat illustration of parallel threads meeting at a mutex, with the C, C++ and Erlang logos.
Concurrency

Protect Shared Data with pthread_mutex_lock

Guard a shared linked-list stack in C with pthread_mutex_lock and pthread_mutex_unlock on glibc 2.41, check return codes, and avoid leaks from missed unlocks.

7 min read
Flat illustration of parallel threads meeting at a mutex, with the C, Go and Erlang logos.
Concurrency

Create and Join Threads with pthread_create

Start threads with pthread_create, wait for them with pthread_join and check the error codes correctly. Includes a complete C program and the mistakes to avoid.

7 min read