Apologies for the last post; got the topic wrong.
What is the current thinking on the best way to solve the shared data
problem i.e. accesssing a shared variable in a non atomic way can give
erroneous results if an interrupt service routine that also changes it
occurs part way through the access.
Standard C doesn't know anything about interrupt routines either, but
you're getting closer because it does know anout signals, which may be
asynchronous.
I suspect what you are looking for is the 'volatile' keyword, that says
that the variable must be re-read every time it is accessed in case it
has changed since the last time. However, the only type which is
guaranteed to be truly 'atomic' in C (in the sense that no other code
can access it in the middle of another access) is char, which is defined
as the smallest addressable element. In practice, most platforms will
probably treat int as atomic, but you really need to look at your
specific hardware.
For anything else, use a volatile char as a lock and use volatile for
any other shared area to disable optimisations based on prior values.
That will slow it down, of course, so keep such accesses to a minimum if
that's a concern.
Or, in the extreme, use system-specific constructs to disable interrupts
(the specific interrupt if you can) round the accesses. You may be able
to do that with inline assembler, for instance (but wrap it in macros in
a header file so it can be replaced for porting).
Chris C