Simple background:
Running freeRTOS on my mcu.
One of the features I have in my project is a library that handles parameters stored in external memories.
Basically at startup, the main function calls the function that reads all the parameters from the external memories and stores them inside the library, in static variables (not global).
Now, I have a couple of tasks that are running. Some of the tasks calls function within the parameter library to read/write from/to the parameters.
Questions: When the tasks calls the function to read a parameter, they are initially trying to access the same variable. Right?
It's not like that each tasks creates their own copy of the whole library?
If that's not the case then I guess semaphores are the way to achieve my goal, and from there I'll be fine.
Two images are uploaded: the first one is the way I assume is correct, and the second one faulty.
ps. No access to any controller. Thus I'm asking here :)
Your assumption is correct. You must remember that you are still compiling a single C program. Your MCU OS is part of your program and doesn't contain a program loader or anything like that, and you only have one main
.
This really means that your program will behave like in any normal C program, there won't be any duplicate variables or hidden traps. The only weird point is that the OS is capable of switching tasks with magic.