I've been tasked with creating a user-level thread library that replicates the functionality of pthread
(full disclosure: this is for an OS course). However, I'm unclear as to how pthread_join()
and pthread_exit()
interact when a thread has already exited.
In particular, the man page states:
The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately.
Is this a guarantee that even if I create millions of threads their results will be kept available for one join? Otherwise, how long can I expect the result to be kept around?
I'm not looking for advice on how to implement it (that's most of the fun!), I'm just trying to nail down the behavior before I dive in.