I am following a course where we are writing an OS on a microcontroller.
The OS is written in C and the instructor initializes stack spaces for each thread in the following way.
int32_t TCB_STACK[NUM_OF_THREADS][STACK_SIZE];
How can the memory be allocated if there isn't any OS already running to service this in the first place? Am I missing something?
You don't have to "allocate" anything as such on a bare metal system, you have full access to all of the physical memory and there's no one else to share it with.
On such a system those arrays end up in statically allocated RAM memory known as .bss
. Where .bss
is located and how large it is, is determined by the linker script. The linker script decides which parts of the memory to reserve for what. Stack, .bss
, .data
and so on. Similarly the flash memory for the actual program may be divided in several parts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.