>On Tuesday, 8 January 2013 06:00:26 UTC, ScannerPrincess wrote:
>On 01/07/2013 07:34 PM, Alun wrote:
>>What about disabling interrupts in the mainline code, making
>>a copy of the variable and then enabling interrupts again?
>>Working with the copy should be safe ...
>>
>>Greetings, Karin
>>
>>
>
>Isn't there then a risk missing an interrupt? I'm not sure about this, but if
>we turn off interrupts I don't think they'd queue until turned back on.
>
>No, no Interrupt will be missed. The IF flags are set regardless of the GIE
>flag setting, and as soon as GIE is enabled again, the interrupt is triggered.
>Last night, I thrashed out what I think is a "thread safe variable" library,
>but getting all the corner cases made it huge (costing at least 300 words) and
>when I wrote a test case for it I realised it provided no way of safely
>incrementing a variable! So I'm coming to the conclusion that a general
>solution isn't practical.
>
>That's why I prefer to only put complex, tedious tasks in a library, like
>converting numbers to decimal strings for output. Some tasks are easily done
>by the main program, but can be very complex and often inefficient to be done
>by a general-purpose-library. There exist libs for A/D-conversion, I believe.
>I have never had a look at them, as I need to look in the datasheet to find
>the analog inputs anyway. The three or four needed commands and assignments
>for the real conversion can quickly be typed. Furthermore, I like to use the
>spare cycles while the conversion is in progress, using the lib, those cycles
>are probably always wasted.
Greets,
Kiste
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.