We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
what is a re-entrant code? again what is re-entrant kernel?
thank you ece tech
Another example is that a function that reads a global resource may have to protect ........
Pers post abbreviated: stay away from reentrancy.
Erik
stay away from reentrancy.
To be more precise - on a '51, stay away from situations where you may need reentrant functions (e.g. recursive functions, multithreading, calling the same function in ISRs and the regular program, etc)
Erik is a bit rough, but when specifically talking about a C51 processor (it doesn't have a real generic stack), reentrancy costs a lot.
For a C51, most parameters and function-local variables are converted to global variables by the compiler and linker. A reentrant function can not have it's parameters or local variables converted to global variables since each active instance of the function must have a separate set of variables. That's the rule I mentioned in my earlier post about reentrant functions often needing syncronized read and/or write access to global resources.
In short, making a function reentrant on a C51 processor costs memory, code size and speed. Few functions really need to be reentrant. It is better to create several copies of the same function. One copy to call from the main loop, and one copy to call from an interrupt handler. Especially if the interrupt handler are already using a different register bank.
when specifically talking about a C51 processor
I am posting based on that. I see no reason to mention that this is specifically about the C51 when the architecture window states C51.
It doesn't matter if a thread is about a specific architecture. If the answer sounds general, the OP may assume that the answer really is valid for other architectures too.