Pthread_* counterparts

Looked over the API reference and I can’t figure out the threading part. I figure out BLocker (or create_sem, delete_sem, acquire_sem, release_sem) are the counterpart of pthread_mutex_t but what is the counterpart of pthread_cond_t? On UNIX I can wait/signal on pthread_cond_t. On Windows it’s Event. What is the preferred mechanism on Haiku?

Standard pthreads are available, so if you are familiar with them, just use them (they are a first class API in Haiku, not some kind of wrapper around native threads, and BeAPI threads and pthreads functions can be freely mixed).
The BeAPI has more limited threading support, it provides mostly what’s required to build the BHandler/BLooper/BMessage system: semaphores, BLocker, areas, and message ports.

Ports can be used to implement inter thread messaging, which is not the same as pthread_cond_t, but can be used to achieve similar things: https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_Ports.html

1 Like

Do I need special import or different headers? I didn’t get my pthreads code to compile so far.

Just include the usual <pthread.h>, no specific libraries or compiler flags needed.