reentrancy and display functions
Posted: Fri Sep 19, 2008 6:38 pm
Is it theoretically possible for a display function to be re-entrant?
I know that it can be thread-safe. Maybe I am having a hard time differentiating between reentrant and thread safe. I have looked around and seen explanations for it, but still don't quite understand it.
re-entrant. Code should refer to global or static or non-reentrant code.
thread-safe. Code can refer to anything, as long as protection mechanisms are used (spinlocks).
How can a running function be re-entered without the use of two threads?
I'm thinking it can only go like this.
re-entrant function
int whatever(int a)
{a += 5; return a;}
main{
whatever(4);
...a += 5;
-----interrupt happens during middle of whatever()
whatever(2);
iret
-----back from interrupt
...return a;
Is this even close? Obviously if whatever() uses spinlocks, execution will stop when the interrupt tries to call it.
I know that it can be thread-safe. Maybe I am having a hard time differentiating between reentrant and thread safe. I have looked around and seen explanations for it, but still don't quite understand it.
re-entrant. Code should refer to global or static or non-reentrant code.
thread-safe. Code can refer to anything, as long as protection mechanisms are used (spinlocks).
How can a running function be re-entered without the use of two threads?
I'm thinking it can only go like this.
re-entrant function
int whatever(int a)
{a += 5; return a;}
main{
whatever(4);
...a += 5;
-----interrupt happens during middle of whatever()
whatever(2);
iret
-----back from interrupt
...return a;
Is this even close? Obviously if whatever() uses spinlocks, execution will stop when the interrupt tries to call it.