AnsweredAssumed Answered

None-interruptable functions

Question asked by Vidar (Z) on Mar 3, 2015
Latest reply on Mar 3, 2015 by Clive One

This might be a silly  "everybody knows that"-question (except me) but are there any atributes/methodes that will prevent a function from beeing interrupted by interrupts while running?

I have a set of functions that deals with ringbuffers where one function puts data into the buffer and another is reading from the same buffer if any data is available. The buffer are controlled by two indexes, and if an interrupt is trying to put something into the buffer while the main system is trying to read its content, possible hickups might occure. There will always be only one reading the buffer, but there might be several that wants to put something into the buffer.

I remember in my earli years when dealing with 8bit AVRs (sorry for mentioning them herein) I simply stored the status register before clearing interrupt enable bit when I wanted to prevent interrupts to be executed under special circumstances, when done I restored the SREG register again. This worked like a charm but I wonder if there are any other and better way to achiev this.

Thanks in advance  

Oh.. I use the Sourcery_CodeBench_Lite_for_ARM_EABI toolset for compiling