This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to caculate the total reentrant stack size in KeilC?

Hi,all

I have succeeded in runing ucos (v2.52) in the keil simulator environment, and still confused about the reentrant functions though I searched it here. reentrant stack is also called simulator stack,right? My OS is xp sp2. Keil is C51.EXE V8.06 My project is complied in large mode.

And the quetions are:

1, Does every reentrant function have Its own reentrant stack? Are there the same number of ?C_XBP as the reentrant functions.

2, For all the reentrant functions, Arguments and local variable are stored in the simulator stack,right? If all the functions in my project are reentrant. is
there no hardware stack wanted? if not what is it for?

3,How can I know each or the total simulator stack size ?Can I get it from the map file? or other ways.

Thanks

Parents
  • The software stack for reentrant functions works just like you would expect a "normal" stack for "normal" C to work. That is, there's a stack pointer, and values get pushed and popped on the stack as the call chain goes up and down. It's only called a "software stack" or "simulated stack" because the 8051 doesn't have much in the way of pointer registers, and Keil wants a clear distinction between this stack and the "hardware" stack that uses the SP register. The stack pointer is a variable, not a register, which means there's more code to manipulate that pointer than is usual with other architectures.

    Different memory models change the names slightly.

    As was mentioned, every task will need its own stack (as is usual with a preemptive OS). The task-switching code for your OS will need to be aware of the software stack implementation, and will have to store ?C_XBP in the task control block and change it out on task switches as it does with all the other registers. Since the stack implementation is unique to Keil, your uCOS code may or may not already have support for this. (Someone may have done the Keil-specific port already; if not, you get to learn about the internals of the uCOS kernal.)

Reply
  • The software stack for reentrant functions works just like you would expect a "normal" stack for "normal" C to work. That is, there's a stack pointer, and values get pushed and popped on the stack as the call chain goes up and down. It's only called a "software stack" or "simulated stack" because the 8051 doesn't have much in the way of pointer registers, and Keil wants a clear distinction between this stack and the "hardware" stack that uses the SP register. The stack pointer is a variable, not a register, which means there's more code to manipulate that pointer than is usual with other architectures.

    Different memory models change the names slightly.

    As was mentioned, every task will need its own stack (as is usual with a preemptive OS). The task-switching code for your OS will need to be aware of the software stack implementation, and will have to store ?C_XBP in the task control block and change it out on task switches as it does with all the other registers. Since the stack implementation is unique to Keil, your uCOS code may or may not already have support for this. (Someone may have done the Keil-specific port already; if not, you get to learn about the internals of the uCOS kernal.)

Children
No data