Questions tagged [pthreads]
The pthreads tag has no summary.
11 questions
1 vote
2 answers
166 views
Where to initialize clients in C server?
I’m writing a multiplayer server in C using sockets and pthreads. The project is separated by responsibility: server.c/.h → networking (socket, bind, listen, accept, thread creation) player.c/.h → ...
0 votes
1 answer
246 views
An adaptor layer for Pthread, C11, and C++11 threads compatibility
As my next spare-time project, I'm considering writing a suite of compatibility header and associated library, that eases the transition from Single Unix Specification v4 to v5 and C11/C17 to C2X. C++ ...
-2 votes
1 answer
394 views
How should functions that keep state across multiple invocations be made safe?
In Computer Systems: a Programmer's Perspective, 12.7.1 Thread Safety When we program with threads, we must be careful to write functions that have a property called thread safety. A function is said ...
2 votes
0 answers
2k views
multithreading - waiting on a condition without using locks (c++11)
i've been wondering about it for a while now but never found any answers. is it possible to use something like a condition variable without a lock? I have a vector of objects, and a thread pool, and ...
0 votes
2 answers
668 views
pattern to unlock thread and get variable in fast unlock
I have a thread that goes in a loop doing something like this void thread() { pthread_mutex_lock(mutex); for ( ; ; ) { /** code **/ { pthread_mutex_unlock(mutex); /** ...
0 votes
0 answers
1k views
using pthread_cond_broadcast with no mutex or waiting thread?
Assuming some pthread_cond_t condvar; properly initialized with pthread_cond_init am I allowed to pthread_cond_broadcast it without any mutex locked and thread blocked with pthread_cond_timedwait on ...