FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2013 Threads] Stack used for function callsPosted by dev on January 27, 2013 As I know every task get assigned some stack(configured by user) from heap. Does function call from a task uses the same stack which has been assigned to particular stack ? (Yes, Got from same website while browsing through other questions) also what about nested function ? (Yes , assumption) Can you please give some pointer(Book, threads) to know more about memory allocation for function calls?
RE: Stack used for function callsPosted by MEdwards on January 27, 2013 How memory is allocated in functions has nothing to do with FreeRTOS, and everything to do with your compiler. If you want to learn about this stuff you would find the answers in a C book not an RTOS book.
If you declare a local non static (does not use the static key word) variable inside a function then the compiler will wither allocate space for the variable on the stack or just hold the variable in a register. In most cases it will be on the stack if the compiler optimization is low, and in a register if the optimization is high. In both cases every task that calls the function will get a different copy of the variable and the function is said to be re-entrant.
If you put the word static in front of the variable declaration then the variable will instead be held in a global data pool just like global and file local variables. In this case every task that calls the function will use the same variable, and the function is said to not be re-entrant.
RE: Stack used for function callsPosted by dev on January 27, 2013 I am a novice never worked on RTOS , please bear with me Please clarify below doubt Task#1 - Has been allocated with Stack#1 from configTOTAL_HEAP_SIZE Task#2 - Has been allocated with Stack#2 from configTOTAL_HEAP_SIZE
If task#1 has called a function#1 (the called function#1 may call another function#2) , the local variables of function#1 and function#2 will be placed in which stack ? Stack#1 ? or some FreeRTOS uses some global stacks to be used for these things.
RE: Stack used for function callsPosted by Richard Damon on January 27, 2013 Tasks are no different than any other function in your program (including main). When one function calls another, they use the same stack, so if the function that implements task#1 calls function#1, that function (for this call) will use the stack space from task#1. If the function that implements task#2 calls the same function, then for that call, it will use task#2 stack.
There are some ports that will move the Interrupt stack to a different space, so that you do not need to reserve space for the interrupts in every task, but that is something different.
RE: Stack used for function callsPosted by dev on January 28, 2013 Thanks, now i got clear picture
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|