 RealView Libraries and Floating Point Support Guide |
|
| Introduction to reentrancy and thread‑safety2.2.1. Introduction to reentrancy and thread‑safetyReentrancy and thread‑safety are both related to the way functions handle resources. However, they are different: A reentrant function does not hold static data over successive calls, nor does it return a pointer to static data. For this type of function, the caller provides all the data that the function requires, such as pointers to any workspace. This means that multiple concurrent invocations of the function do not interfere with each other. NoteA reentrant function must not call non reentrant functions. A thread‑safe function protects shared resources from concurrent access using locks. Thread‑safety concerns only how a function is implemented and not its external interface. In C, local variables are dynamically allocated on the stack. Therefore, any function that does not use static data, or other shared resources, is usually thread‑safe.
|
|