Reputation: 85
I have a queue where the put and pull functions of the queue are called when different interrupts happen. Is there a way to prevent race condition in this scenario? While we can not wait on semaphores in interrupt service routines what is the best way to create a similar functionality. We are using an ARM-Cortex A5 processor of a Zynq FPGA to develope the code.
Upvotes: 2
Views: 1158
Reputation: 25286
Assuming that each interrupt causes the "Interrupt Disabled" state of the processor to be turned on, and assuming that the interrupts you are handling have the same priority (that is, one can't interrupt the execution of the other), then there already can be no race condition and your ISRs can just access the shared queue.
(When an interrupt occurs, the processor goes into interrupt disabled mode, pushes all registers onto the stack, jumps to the ISR entry point and continues execution there. Once the ISR is done, the "iret" instruction does the reverse of the entry. This simple description can be implemented differently in different processors and platforms.)
Upvotes: 3