Hi,
I've been unable to find any way of doing a proper test-and-set command
in C/C++... anyone know a way of doing this?
This is going to be executed in a signal, possibly re-entrant, so it
can't be wrapped in a semaphore, mutex, or anything else : it has to be
a single, atomic, test-and-set operation which cannot possibly be
interrupted or pre-empted. This is also executing in a threaded environment.
I've seen various pieces of sample code stupidly claiming to be test and
set, such as 'if (i==0) {i++; return true;}', but haven't found anything
which is basically an exposure of the underlying atomic hardware
instruction.
Vin
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!