Developers and testers are obsessed with ensuring (or avioding) the reentrancy. Organizations always analyze it specially (e.g. this one says: Many functions must complete their execution and return before they're called again, in order to avoid problems
). But what is so specific about it?
Actually, I can reenter in two ways: by (single-threaded) recursion and simultaneously, using two parallel threads. Why nobody tells about this or can say which of the cases is considered in the reentrancy issue? The wikipedia article starts by ISR (which seem a kind of multi-threading), then continues with recurrence and then finishes introduction mentioning multi-threading.
Ok, recurrence can be a problem. There can be stack overflow and we can forget to exit the loop in some cases. But why to call this re-entrancy problem?
Multithreading has nothing to do with this. Mulththreading analysis concentrates around use of shared resourses. Yes, re-entrant function, executed simultaneously by two threads, will access the same global (shared) variable and care must be taken. But executing two different procedures simultaneously may also result in the same problem because the same global variable is not limited for access from this single (reentrant) procedure. Producer and consumer call different procedures. Why do not want you to do the same analysis for this case and use critical sections only in reentrant procedures? If you do not enclose your shared variable access to reentrant procedures (and nobody does) then why to treat them differently?
IMO, the recurrence and atomic access to shared objects in multithreading are two absolutely different problems, which have nothing to do with each other. Different analysis techniques are used to analyze them you must think differently when address them. Why to repeat these two analyses under the reentrancy pretext? What if I copy my function and one will call another or these sister functions will be called simultaneously? What if functions are not exact copies of each other? Can I overcome the reentrancy problem this way?