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 reentrant function?
One which can be called again while it's already running; eg, a recursive call. Reentrant functions need special handling in C51 due to the restrictions resulting from the 8051's restricted architecture (particularly lack of stack space). See the manual.
A simple answer: A function MUST ne reentrant if it is a) a function called both from main and interrupt(s) b) a function called by more than one task in a multitasking system. Erik
You list requirements of a reentrant function, not a definition. A reentrant function must be able to be re-entered at any time while executing. Thus it may not use static data. You either pass in the context upon which to operate or use stack based variables. The use of stack based variables causes some performance issues with C on the 8051 since a reentrant stack must be created and used. - Mark
Nice definition. I'll add one more thing. Reentrant functions are not necessarily recursive. A recursive function is one that calls itself (directly or indirectly). Jon