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.
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.
On Tuesday, 8 January 2013 06:00:26 UTC, ScannerPrincess 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 ...
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.
Making it general is presumably as simple as having two functions and scattering those throughout the code where needed:
oldstate = maskinterrupts() -- returns previous GIE value
...
restoreinterrupts(oldstate) -- puts it back.
Hi Kiste
When interrupts are disabled, there won't be interrupt anymore, they won't queue until you enable them again. Right? Am I missing something ?
Cheers
Seb
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
When interrupts are disabled, there won't be interrupt anymore, they won't queue until you enable them again. Right? Am I missing something ?
OK great thanks for the clarifacation
Cheers
Seb
--