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 I want each thread to access a specific cell once than go to wait for the master thread (that currently waits) to "broadcast" for another access. as far as i know the vector access is thread-safe, and since all threads go to wait for broadcast before the master thread comes, there is no real need for a lock there, yet pthread_cond requires a lock, and i found no other implementation for a conditional wait with no lock.
so it there an implementation in c++ using pthreads that waits on a condition without locks and also without spinning? Thanks.
[of course i could use a lock but then i lose the benefit of parallelism. another solution is having a mutex for each thread and have an array of mutexes at the master thread, but that seems like a lot of overhead.]