What is the meaning of reentrant? What are the problems with reentrancy?
A function may [should!] be reentrant, which means that it may be invoked again (re-entered), while it is still referenced by one of the program-flow contexts (stack frame, thread context). Synchronous reentrancy pitfalls include static state [i.e. static data (static variables), or global data], which is overwritten by multiple function invocations (either explicit, implicit [i.e. indirect; often difficult to tell, see errno problem], or through recursion). Asynchronous reentrancy pitfall situations include multithreading and signals [or interrupts, e.g. in interrupt-based embedded systems]. It doesn’t usually matter if the underlying hardware is a single-processor system or a multi-processor system; however the chances of asynchronous problems occurring are typically higher on multi-processor systems [due to their finer-granular concurrency {not just interruptions by task-switches, only every microsecond or so}]. Libraries may contain non-reentrant functions, that either require to k