Атомное приращение не работает должным образом в прерыванииC++

Программы на C++. Форум разработчиков
Гость
Атомное приращение не работает должным образом в прерывании

Сообщение Гость »


У меня есть Google Coral Dev Micro с SoC RT1176 (800 МГц Cortex-m7 и 400 МГц Cortex-m4), m7 работает под управлением FreeRTOS, а m4 работает под управлением «голого железа», компилируется с использованием GCC none eabi 9.3.1 со следующим флаги:

Код: Выделить всё

-Wall -Wno-psabi -mthumb -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs-frame --specs=nano.specs --specs=nosys.specs -u _printf_float -std=gnu99 -g -Os -save-temps -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DNDEBUG
I want to communicate data generated in a timer interrupt between the two cores using shared memory and I have created my own lock-less FIFO buffer in shared memory:
fifo.h:

Код: Выделить всё

#include 
#include 
#include 
#include 

template 
class LockLessFifo {
public:
LockLessFifo() : read_idx(0), write_idx(0), buffer({0}) {}

size_t size() {
if (read_idx 

Источник: [url]https://stackoverflow.com/questions/78068613/atomic-increment-does-not-work-as-expected-in-interrupt[/url]

Вернуться в «C++»