Skip to main content
Visitor II
April 6, 2025
Solved

H743 FreeRTOS

  • April 6, 2025
  • 3 replies
  • 911 views

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.
    Best answer by mƎALLEm

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

    3 replies

    Super User
    April 6, 2025

    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.

    Visitor II
    April 6, 2025

    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)

    Super User
    April 6, 2025

    Right, problem solved. 

    -> use global volatile variable.

    Technical Moderator
    April 6, 2025

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

    Visitor II
    April 6, 2025

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

    mƎALLEmAnswer
    Technical Moderator
    April 6, 2025

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

    Super User
    April 6, 2025

    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