Thread Safety: a function is called thread-safe, and it always produces the correct result when and only if it is repeatedly invoked by multiple concurrent processes. If a function is not thread-safe, we say it is thread-unsafe.
reentrant: The function is called by a different control flow, and it is possible to enter the function again when the first call has not returned;
non-reentrant function: A function accesses a global list, which may cause confusion because of the reentry;
Reentrant functions: If a function accesses only its own local variables or parameters, a
reentrant function avoids thread-unsafe problems caused by access to other functions. Functions that can be reentrant are thread-safe.
As with global linked lists, it is possible to insert errors caused by a thread's problem while inserting two nodes at the same time, which causes the thread to be unsafe because its operation is not atomic and thus causes different actions to occur at the same time.
As in the example above, it is possible to have a dislocation caused by a reentrant, which is called a non reentrant function. we know that the reentrant function is a thread-safe function. If a function can be reentrant when multiple threads are said, this function is said to be thread safe. This does not mean that the function can be reentrant for a signal handler. If the function is safe for the reentry of the program at the asynchronous signal, it is said that the function is safe for the asynchronous signal. in general, a reentrant function is a thread-safe function, but a thread-safe function is not necessarily a reentrant function. use a picture to show it ~