Reputation: 36
I want to know if there is a possibility for a function to be thread safe but not reentrant. In some websites, they say that it's not possible, whereas others say it is possible. Examples given by them who say that it's possible are not clear. So is it possible to have a function that's thread safe and not reentrant? Is there a clear example to prove this point?
Upvotes: 1
Views: 922
Reputation: 19471
Example from this article: http://en.wikipedia.org/wiki/Reentrancy_%28computing%29
int function()
{
mutex_lock();
...
function body
...
mutex_unlock();
}
If an interrupt interrupts this function and the interrupt handler calls this function the system will hang forever as the first function locked the mutex.
Upvotes: 2