I attended an interview today in which the interviewer asked me the following question :
Is re-entrancy and mutual exclusion thread-safe ? Can you explain why ?
I am relatively new to concurrent programming and could not answer it.. But i said ...
Mutual exclusion is thread safe . But re-entrancy is not and that is the reason why we have re-entrant locks .
The interviewer moved on to the next question though to a different area ... I think i messed this one up ...
What is he expecting me to say when he asked me this ?
Proper answer should be:
Yes they are implementation of Thread safety.
re-entrancy
Writing code in such a way that it can be partially executed by one task, reentered by another task, and then resumed from the original task. This requires the saving of state information in variables local to each task, usually on its stack, instead of in static or global variables.
one example
Mutual exclusion
Access to shared data is serialized using mechanisms that ensure only one thread reads or writes the shared data at any time. Great care is required if a piece of code accesses multiple shared pieces of data—problems include race conditions, deadlocks, livelocks, starvation, and various other ills enumerated in many operating systems textbooks.
one example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With