Why are malloc() and printf() said as non-reentrant?
In UNIX systems we know malloc() is a non-reentrant function (system call). Why is that? Similarly, printf() also is said to be non-reentrant; why? I know the definition of re-entrancy, but I wanted to know why it applies to these functions. What prevents them being guaranteed reentrant? malloc and printf usually use global structures, and employ lock-based synchronization internally. That's why they're not reentrant. The malloc function could either be thread-safe or thread-unsafe. Both are not reentrant: Malloc operates on a global heap, and it's possible that two different invocations of