A brief definition of re-entrant that works for me is:
The function can be called from two different places in the
application (say interrupt and main-line code or two threads) at exactly the
same time without interaction or any adverse effects to either calling
function for example the returned result is what the programmed expected in
each case.
There are possible better definitions I think the K&R ANSIC C book has a
very good definition. Hope this helps in my opinion this is a very
important thing to get right as re-entrant function can be a beautiful tool
to the programmer if used correctly. But note well it can be a nightmare or
any street if it is got wrong as often you cannot say where it all started
to go wrong.
Examples for re-entrant code
int FnDivide( int param1, int param2 )
{
return( param1 / param2 );
}
This example is very simple and may not work on the 8051 but because the
stack is used to pass the parameters and return the result this function
although simple is an example of a re-entrant function. Re-entrancy means
you should have an understanding of the output produced from the compiler
(this is mandatory I would say for any embedded software engineer).
Hope this helps I would strongly suggest that anybody using C to write
programs embedded or otherwise gets a copy of the K&R ANSIC C book this is
the best description of the standard I have seen.
Regards,
Rod Boyce.
-----Original Message-----
From: cheng chung yan [mailto:***@hkem.com]
Sent: Wednesday, 14 February 2001 22:25
To: sdcc-***@lists.sourceforge.net
Cc: ***@microtek.com.cn
Subject: [Sdcc-user] want to know more about
reentrant
dear Dai Yuwen
thanks your response.
as the question of "reentrant", i study the sdcc document,
but i can't get the understanding. Could you please tell me more?
thanks
yan
_____________________________________________________
Sent by Hong Kong E-Mail at http://www.hkem.com
It's free. It's easy. Sign up your account Now!
_______________________________________________
Sdcc-user mailing list
Sdcc-***@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/sdcc-user