Questions tagged [reentrancy]

Reentrancy usually refers to subroutines, functions, methods and mutexes. A subroutine is considered reentrant if it can be safely called before a previous call has completed.

To be reentrant a subroutine, function, method etc must:

  • hold no static (or global) non-constant data
  • not return the address to static (or global) non-constant data
  • work only on the data provided to it by the caller
  • not rely on locks to singleton resources

A reentrant mutex's lock can be acquired multiple times by the same thread. However, the lock must be released the same number of times or else other threads will be unable to acquire the lock. It has some similarities to a counting semaphore. More info here: Reentrant mutex

See also

214 questions
-1
votes
1 answer

DllMain DLL_PROCESS_DETACH and GetMessage Function reentrancy

I have written a global hook that hooks using SetWindowsHookEx the WH_GETMESSAGE, WH_CALLWNDPROC and WH_CALLWNDPROCRET. The hook dll creates a new thread in the hooked process, which, among other things, checks the audio state of the process and…
Roland Pihlakas
  • 4,246
  • 2
  • 43
  • 64
-1
votes
1 answer

Uses of reentrant code?

What are examples of types of applications or methods that should be reentrant? Or is it something that you should generally strive for? Also, is it generally a given in (pure) functional programming that your code will be reentrant?
user65663
-2
votes
1 answer

Is register value corruption a possibility on reentrant functions in ARM C?

Maybe I'm overthinking this since I've been researching for a couple of hours. I have the concept and rules of reentrancy pretty clear now but since I'm doing this for ARM (Cortex-M4), another question came to mind that is not touched on the…
m4l490n
  • 1,592
  • 2
  • 25
  • 46
-2
votes
1 answer

Is the function who contains thread-local variable re-entrant?

Take the following code using thread_local variable as an example: void func() { thread_local int a; ...... } According to Wikipedia, I know it is a thread_safety function. But should we call it also a re-entrant function?
Nan Xiao
  • 16,671
  • 18
  • 103
  • 164
1 2 3
14
15