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

Reentrant Function call

Hi.
I m using 89C51. I have made all those functions that are called from non-ISR as well as ISR as reentrant and defined reentrant stack in XDATA. Here, i want to know that for each call to reentrant function, process will do the PUSH and POP operation to store local variables and function's arguments on simulated reentrant stack or only in those cases when interrupt occurs during the execution of reentrnat function ?

Parents
  • I was facing a problem regarding recursion. For some functions that must be recursive for my code. While i m builing the code, linker gives error for recursive call. So to avoid this, i made all those functions reentrant, even though those functions are not called from any ISR at all.
    HOW can a function be recursive without being reentrant??????

    But my concern is that during each call to these function, processor will perform PUSH & POP operation which will slow down the performance.
    You can not have your cake and eat it too. Either you design your program before you code it or you just code away happily and end up in the mess you are in.

    So can you suggest the way to achieve this. Instead of making those functions reentrant
    Sure 1) NO recursive functions 2) NO reentrant functions

    Will it be good to use overlay option instead of making all functions reentrant ??
    The overlay that get active at optimization 2 and up can NOT be used (for physical reasons - not the compilers fault) for functions that are reentrant or recursive.

    If you had not been concerned with speed, there MAY have been ways to save your code, but sicnce you are only one way exist: Throw away you code, design the project to be non-reentrant and non-recursive and start over. Sorry, but I see no other way.

    Erik

Reply
  • I was facing a problem regarding recursion. For some functions that must be recursive for my code. While i m builing the code, linker gives error for recursive call. So to avoid this, i made all those functions reentrant, even though those functions are not called from any ISR at all.
    HOW can a function be recursive without being reentrant??????

    But my concern is that during each call to these function, processor will perform PUSH & POP operation which will slow down the performance.
    You can not have your cake and eat it too. Either you design your program before you code it or you just code away happily and end up in the mess you are in.

    So can you suggest the way to achieve this. Instead of making those functions reentrant
    Sure 1) NO recursive functions 2) NO reentrant functions

    Will it be good to use overlay option instead of making all functions reentrant ??
    The overlay that get active at optimization 2 and up can NOT be used (for physical reasons - not the compilers fault) for functions that are reentrant or recursive.

    If you had not been concerned with speed, there MAY have been ways to save your code, but sicnce you are only one way exist: Throw away you code, design the project to be non-reentrant and non-recursive and start over. Sorry, but I see no other way.

    Erik

Children