What is joining and forking threads?

Frosty555
Frosty555 used Ask the Experts™
on
I have a high level understanding of threads, mutexes, etc. and about avoiding race conditions, sharing memory etc between threads, and making threads sleep / how timesharing works between threads and processes.

But my knowledge is very high-level, I'm used to using thread libraries like what is provided by .NET, Java or the QT library.

What does it mean to "fork" a thread, or "join" a thread, when you're dealing with POSIX threads in C? Also what is thread "signalling", if such a thing exists?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
jkr
Top Expert 2012
Commented:
IMO the best reading on this: https://computing.llnl.gov/tutorials/pthreads/ ("POSIX Threads Programming") - resp. https://computing.llnl.gov/tutorials/pthreads/#Joining ("Joining and Detaching Threads") and https://computing.llnl.gov/tutorials/pthreads/#ConVarSignal ("Waiting and Signaling on Condition Variables") in particular.
Director - Software Engineering
Commented:
"fork" a thread

you can't really fork a thread. You fork a process. Forking in the Unix world creates a new process whereas a thread is not a new process but runs within the context of a single process. So there's a lot more overhead with forking as opposed to creating a thread.

"join" a thread
This is a way to synchronize. So the calling thread which calls for a join waits till the other thread for which it is waiting completes whatever it has to do and then joins it. Here is a snippet from MSDN

Here are a couple more links for a quick overview
http://www.cs.mtu.edu/~shene/NSF-3/e-Book/FUNDAMENTALS/threads.html
https://computing.llnl.gov/tutorials/pthreads/
trinitrotolueneDirector - Software Engineering

Commented:
so with Windows you call CreateProcess() if you want to create a new process but though similar this is not identical to forking a process on Unix

Commented:
By the word "fork a thread", are you asking how to start a thread?
If that is so, then you should use pthread_create() call to create a new thread.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial