Atomic Operations (continuing on from Masking Interrupts?)
Wed Jul 7 03:47:00 GMT 1999
"Robert J. Brown" wrote:
> The problem is that there is no language enforced way to insure that
> enables are balanced with disables, and inhibits are balanced with
> restores. The use of a subroutine that takes a thunk as its sole
> argument, such as my "without_pre_emption(thunk)" example above,
> forces the programmer to keep things balanced. The only real
> trouble-maker is throwing an exception, or taking a longjump. Lisp
> provides "unwind-protect" for that situation.
Use C++. Create a classlet where the constructor saves the interrupt
mask and disables interrupts, and the destructor restores the status quo
ante. Create one of these on the stack; when it goes out of scope
interrupts are restored.
Of course you then suffer the perils of C++, but that's another story
Tel: +44 1223 566919 Fax: +44 1223 566915
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
To remove yourself from the crossgcc list, send
mail to email@example.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.
More information about the crossgcc