[NSWI004] Questions
Petr Tuma
petr.tuma at d3s.mff.cuni.cz
Fri Nov 6 20:06:57 CET 2020
Hi,
> 1) I'm still not sure what I am supposed to do if a thread calls thread_finish, when it is not done with its entry function.
It should just stop executing, leaving the entry function unfinished. Imagine you called `exit()` in the middle of your `main()` function in a normal program - that would also terminate your program at that point, regardless of the fact that the `main()` function may have more code after the call to `exit()`.
> 2) What about if t1 calls join on t2, and then t2 calls join on t1? Isn't there some sort of 'deadlock', where they both are waiting for each other to finish?
Yes, that would be a deadlock. You are not required to address situations such as this one - this is simply a problem for whoever is calling the joins in this strange manner (and yes, the threads in the kernel would simply remain deadlocked unless some external event terminated one or both).
Petr
More information about the NSWI004
mailing list