Reentrant
From Texas Instruments Embedded Processors Wiki
Translate this page to
A function is considered reentrant if it can safely be called again while another instance of the function is currently executing, possibly in another thread, interrupt, or process.
Some RTS functions are reentrant, such as abs. Many are not, such as printf.
The topic of whether a function is reentrant or not is a complicated one; you can't simply list functions as being reentrant or not reentrant, you have to specify under which conditions a function is non-reentrant. Sample reasons a function might not be reentrant:
- Modifies global state (e.g. printf)
- Requires static state (e.g. strtok)
- Re-uses static storage (e.g. asctime)
In principle, any function which could set errno is *not* reentrant.
Leave a Comment