Part Number: TMS320C6747
Hello,
I am trying to implement a queue for our project using the TMS320C6747 DSP. We are using SYS/BIOS and the queue is used to communicate between Tasks as well as between Task and Hwi.
The Compiler is CGT C6000 v8.3.13. I need some clarification on the following section from the compiler's user guide (SPRUI04D, www.ti.com/.../sprui04g.pdf
Section 8.6.9 Using Intrinsics for Interrupt Control and Atomic Sections contains the following code example and says:
These intrinsics [_disable_interrupts(), _enable_interrupts( )] provide a barrier to optimization and are therefore appropriate for implementing a critical (or atomic) section.
unsigned int restore_value;
restore_value = _disable_interrupts();
if (sem) sem--;
_restore_interrupts(restore_value);
The variable name `sem` used in the example implies some form of semaphore. My question is about the code surrounding the critical section:
Are all memory writes that appear before the call to _disable_interrupts() in source code guaranteed to be emitted before the call to _disable_interrupts() in the compiled binary? I could not find this guarantee inside the user guide.
Context:
We need to set a flag inside the critical section to signal that new data is available. But obviously the data has to be written to memory first. If the compiler reorders the memory write to after the critical section, the program would break. I would prefer not to move the memory write of the data inside the critical section, because the data is quite large.
Thank you very much for your support.