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
7
votes
2 answers

What strategy to use in Java for hierarchical reentrant read/write locking?

I'm looking for en efficient system to have a series of read/write locks organized hierarchically to manage access to hierarchically organized resources. If a subtree is locked for write, then no other lock should be able to be obtained in the whole…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
7
votes
1 answer

What does “Using non reentrant iterator method: Array.iterator()” error message mean?

This is my first project in libGDX and I am trying to loop a com.badlogic.gdx.utils.Array: //properties ... private Array items; ... //constructor ... items = new Array(); ... //render method ... for (Item item : items) { …
Waqleh
  • 9,741
  • 8
  • 65
  • 103
7
votes
2 answers

Is Tesseract(an OCR engine) reentrant?

I am doing OCR using Tesseract on a quad-core processor. For better speed, I want to read 4 words at a time, using 4 threads. Is it safe to call Tesseract from multiple threads concurrently? Note: each thread will be working on a different,…
Hristo Hristov
  • 4,021
  • 4
  • 25
  • 37
7
votes
4 answers

Recommended practices for re-entrant code in C, C++

I was going through a re-entrancy guide on recommended practices when writing re-entrant code. What other references and resources cover this topic? What lint-like tools can be used to check for these issues?
Fanatic23
  • 3,378
  • 2
  • 28
  • 51
7
votes
4 answers

Reentrancy and Reentrant in C?

I am reading a book called Linux System Programming. Quoting from this book: What about system calls and other library functions? What if your process is in the middle of writing to a file or allocating memory, and a signal handler writes to…
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
7
votes
2 answers

Why is this code considered reetrant and what exactly happens when the OS interrupts a thread?

Here's a snippet of code that IBM says is reentrant: /* reentrant function (a better solution) */ char *strtoupper_r(char *in_str, char *out_str) { int index; for (index = 0; in_str[index]; index++) out_str[index] =…
brimaa
  • 169
  • 3
  • 11
7
votes
2 answers

Handlebars: recursive tree structure

I have a tree structure of arbitrary depth that I want to display with Handlebars. I don't see any way to recurse. If I knew the depth, I could hard code it I suppose, but it can be arbitrarily deep. Something like this, but it needs to recurse at…
Chris Kessel
  • 5,583
  • 4
  • 36
  • 55
7
votes
2 answers

Does framework have dedicated api to detect reentrancy?

I want to prohibit reentrancy for large set of methods. for the single method works this code: bool _isInMyMethod; void MyMethod() { if (_isInMethod) throw new ReentrancyException(); _isInMethod = true; try { ...do…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
7
votes
2 answers

Fluent Interfaces - Ensuring a new instance

I have a class that exposes a fluent interface style that I also want to be thread safe. At the moment, calling chainable methods on an instance of the class sets up various collections with operations (Func's). When the result is requested the…
Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162
6
votes
1 answer

Is pushing a variable onto an array a threadsafe operation?

I have the following Perl code: push(@myArray, $myValue); Is the operation atomic, or will I need to use locks, if multiple threads will be performing this same operation on many threads?
Mike
  • 23,892
  • 18
  • 70
  • 90
6
votes
3 answers

Reentrant library design in C

Let's say I'm building a library to spork quuxes in C. Quuxes need two state variables to be sporked successfully: static int quux_state; static char* quux_address; /* function to spork quuxes found in a file, reads a line from the file each…
Vinko Vrsalovic
  • 330,807
  • 53
  • 334
  • 373
6
votes
4 answers

Reentrancy and recursion

Would it be a true statement to say that every recursive function needs to be reentrant?
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
6
votes
2 answers

Does an interrupt handler have to be reentrant?

I'm using a static variable inside an interrupt handler, making the interrupt handler non-reentrant. Is it OK to have a non-reentrant interrupt handler? When a hardware interrupt is raised, does the event go in some sort of a queue and wait for…
Arash Fotouhi
  • 1,933
  • 2
  • 22
  • 43
5
votes
5 answers

Is the memcpy() function reentrant?

I call some C++ functions inside a signal handler and my program is terminated by segmentation fault. When I check with gdb, memcpy() function is where i get SIGSEGV. I would like to know if memcpy() is a reentrant function or not?
korhan
  • 301
  • 1
  • 3
  • 6
5
votes
1 answer

Is match(Uri) of class UriMatcher reentrant?

The examples that I have seen of how to make a ContentProvider have all used the UriMatcher#match(Uri) method within the insert, query, update, and delete methods to easily handle all of the URI patterns that the content provider responds to (e.g.:…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
1 2
3
14 15