B
Bob from Chesham Bois
[ Earlier incomplete post sent by mistake - sorry! ]
Can using "register make C++ code non-reentrant? For example:
int myIncrement ( int myinput)
{
register int newint = myinput;
newint++;
return newint;
}
If two threads enter this function concurrently, will they share the
same hardware register for "newint"? In which case the second thread
may overwrite the value that the first thread stored in the register.
Is this a danger? Whereas if the "register" declaration is not used,
there is no danger, because each thread has its own "newint" on its
stack.
Can using "register make C++ code non-reentrant? For example:
int myIncrement ( int myinput)
{
register int newint = myinput;
newint++;
return newint;
}
If two threads enter this function concurrently, will they share the
same hardware register for "newint"? In which case the second thread
may overwrite the value that the first thread stored in the register.
Is this a danger? Whereas if the "register" declaration is not used,
there is no danger, because each thread has its own "newint" on its
stack.