2025-04-05 5:12 PM
HI I m using H743 Nucleo, to write a RTOS program with 2 tasks which gonna access to the same memory location concurrently.. can anyone advise which RTOS method to use ? Tasks ? Semaphore? Message Queue?
2025-04-06 12:24 AM
Hi,
Depends on what you want:
- just use it on both tasks: make a global volatile variable
- have some control, when a task is allowed to use it: use a semaphore
Don't forget, you are on a single core here, so it's never really concurrent in many tasks, it's always only one task running for some milliseconds, then the other or next.
2025-04-06 3:44 AM
Hello,
What do you mean by "access to the same memory location concurrently"?
Even with RTOS only one instruction is executed at a time. The RTOS scheduler makes the tasks seem to be executed in parallel.
STM32H743 MCU is a single core product. There is no worry about the HW concurrence to a memory.
Now if you are talking about mutual exclusion on a specific variable, structure etc, this is another thing.. You need to manage it with mutex or semaphore ...
2025-04-06 4:17 AM - edited 2025-04-06 4:18 AM
Sounds like what you really need is a tutorial on FreeRTOS (maybe RTOS in general) - none of this is specific to STM32.
https://www.freertos.org/Documentation/01-FreeRTOS-quick-start/01-Beginners-guide/00-Overview
2025-04-06 6:59 AM
How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?
2025-04-06 7:26 AM
ok agree, not concurrent but simultaneously... in this case, could the 2 tasks access to the same memory location (where ext. input data from ADC are stored)
2025-04-06 7:50 AM - edited 2025-04-06 8:02 AM
@HMSEdinburge wrote:
How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?
If you are not familiar with RTOSes, I suggest you to learn about it.
and especially mutexes: see that video: https://www.youtube.com/watch?app=desktop&v=I55auRpbiTs&t=0s
"not concurrent but simultaneously... in this case, could the 2 tasks access to the same memory location"
Nothing is done simultaneously in RTOS. As I said, with RTOS only one instruction is executed at a time. The RTOS scheduler makes the tasks seem to be executed in parallel.
@HMSEdinburge wrote:
How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?
That doesn't have a specific relation with STM32.
2025-04-06 7:50 AM
Right, problem solved.
-> use global volatile variable.