2 ms·
Yeah, I would argue that both of those functions are re-entrant. The question is whether you can have two calls to is_not_reentrant executing concurrently witho
by probablybanned 12y ago
Yeah, I would argue that both of those functions are re-entrant. The question is whether you can have two calls to is_not_reentrant executing concurrently without interfering with each other. So a typical example would have a non-reentrant function altering a variable like global_int as part of its computation.
Also, it's important to think about the kinds of program transformations that the C compiler is free to do with your code when going from C to assembly. I think it's likely that your compiler would produce the same output for both functions. Lines of C code do not execute atomically, and instructions can be re-ordered.
EDIT: Returning to this because I think I made a mistake. "Two calls executing concurrently" is not exactly right, because it admits the possibility of arbitrary instruction interleaving. A reentrant function must be able to be paused at any point, have another call to the function execute entirely, and then resume correctly. This is a weaker condition.