Skip to main content
Associate III
Apr 6, 2025 12:12 AM UTC
Solved

H743 FreeRTOS

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? 

This topic has been closed for replies.
mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
Apr 6, 2025 2:50 PM UTC

@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.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.

7 replies

AScha.3
Super User
Apr 6, 2025 7:24 AM UTC

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.

If you feel a post has answered your question, please click on " Best Answer ".
Associate III
Apr 6, 2025 2:26 PM UTC

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)

AScha.3
Super User
Apr 6, 2025 2:50 PM UTC

Right, problem solved. 

-> use global volatile variable.

If you feel a post has answered your question, please click on " Best Answer ".
mƎALLEm
ST Technical Moderator
Apr 6, 2025 10:44 AM UTC

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 ...

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate III
Apr 6, 2025 1:59 PM UTC

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
Apr 6, 2025 2:50 PM UTC

@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.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Andrew Neil
Super User
Apr 6, 2025 11:17 AM UTC

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

https://www.freertos.org/Documentation/00-Overview 

https://www.freertos.org/Community 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.