4 ms·
> pthread_join is a blocking call, and therefore against the spirit of lockless programing. pthread_join will block until the child-thread exists, which means t
by CodeMage 6y ago
> pthread_join is a blocking call, and therefore against the spirit of lockless programing. pthread_join will block until the child-thread exists, which means there's a lock in there somewhere. I personally think the first example they show is a terrible example as a result.
But they didn't use it as an example of lockless programming, did they? They were explaining what "acquire" and "release" mean, and they wanted to explain it in terms the reader should already be familiar with.
In fact, they explicitly say it's not lockless:
In the previous paragraph we have seen how the acquire and release semantics of pthread_create() and pthread_join() allow the creator of a thread to exchange information with that thread and vice versa. We will now see how this kind of communication can happen in a lockless manner while threads run.