William Nicholson

Reentrant Functions

Discussion created by William Nicholson on Mar 15, 2013
Latest reply on Mar 15, 2013 by Jim Donelson

I have search a lot and cannot find virtually anything on reentrant functions in the documentation.  Eventually I came across this statement.

 

When local variables are allocated at fixed addresses, the resulting code is not reentrant. Each function
  must be called only once. Take special care with interrupt functions: they must not call any function which might
  be active at the interrupt time. To be on the safe side, interrupt functions usually use a different set of functions
  than non-interrupt functions.

 

Is this the way all functions work in codewarrior c or is there a way to get codewarrior to support functions which put their local variables on the stack ( MCF51 and codewarrior 10+ but am not sure if this matters ) ??

 

  Some languages have the keyword reentrant for this.

 

If there isnt another way, is the only way do this to add flag to the code to prevent entry into a function while another part of the code is using the function ?  This sounds messy.

Outcomes