What do you exactly mean by Reentrant function?

Hmm... --- so what do you think and the "volatile" keyword are all about?

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker
Loading thread data ...

No. I, for one, definetely refuse to consider referring to an external variable or having a local variable declared static "going out of my way". Those are bog-standard language features. That they're not exactly advisable to be used if re-entrant code is the design goal is a different issue.

The problem is not that the C programmer would have to go out of their way to write non-reentrable code strictly according to the definition you gave earlier --- it's that it's way too *easy* to do so.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

No so. In many compilers for 8 bit systems (the most common on the planet) functions are NOT reentrant. You have to use a keyword to make them reentrant. This is for reasons of space and efficiency. Especially where you only have 128 or 256 bytes of data space.

No so.

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\ /\/\/ snipped-for-privacy@phaedsys.org

formatting link
\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Reply to
Chris Hills

In article , Spehro Pefhany writes

But then most compilers aren't C99 complient :-)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\ /\/\/ snipped-for-privacy@phaedsys.org

formatting link
\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Reply to
Chris Hills

C99 doesn't *require* the libraries to be non-reentrant. ;-)

Best regards, Spehro Pefhany

--
"it's the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
 Click to see the full signature
Reply to
Spehro Pefhany

static

question

Kevin D Quit wrote above

Ok

What is not clear is what data represent. Arguments, globals ?

If *all* data are the same, it is clear that the result will be the same if the code is not altered. I must miss something here.

Reply to
Lanarcam

It is not :) File operations are not guaranteed to give the same result if, for example, you are reading a file that has been unexpectedly deleted between reads.

IMHO, the very definition of "reenterable" as opposed to "reentrant" is far-fetched.

Vadim Borshchev

Reply to
Vadim Borshchev

No idea. The definition of re-enterable and its differentiation from re-entrant seems not to have been made. I thought your original question was about re-entrant functions?

Ian

Reply to
Ian Bell

result

Well, yes but some *data* has changed then, the file itself. This is an event that does not depend presumably on the properties of the function.

I think the discussion leads to nowhere, hence

is

I agree

Reply to
Lanarcam

Me too, it does not make sense.

Ian

Reply to
Ian Bell

Hello Taran,

"Taran" schrieb im Newsbeitrag news: snipped-for-privacy@o13g2000cwo.googlegroups.com...

Reentrant functions are made in a way that they must not use static memory locations. Due to the kind especially C-compilers for 8-bit microcontrollers generate code there is often a special preprocesser directive to be used in order not to make the compiler use static memory locations for (normally) automatic variables, which would in fact result in a non-reentrant code produced from a reentrant looking C source. This is due to the fact that most 8 bit microcontrollers are very limitted in stack space (often only a few 10 bytes), so "wasting" stack space for local variables is no good idea.

Reentrant code must consist purely of code which is reentrant, and it also must not include calls to non-reentrant functions. So a single (write) access to a static memory location can make the whole code non-reentrant.

The best way is to read the manual of the C compiler you use and to have the limittations of the hardware in mind. "Embedded microcontrollers" are anything from a 8051 CPU (with a max. of sometimes only 128 bytes which are shared between registers, stack and variables, 2kByte ROM for program code - even a printf()-routine in 8051 assembler ist larger) to an ARM or POWER PC risc machine with 512 MBytes RAM and 1 GByte Flash memory. Also the architectural differences are enormous: On a 8051 CPU, you have two timers, one you will waste when you are using a RS-232 interface. On a XC167, you have nearly 20 different timers, packed in Groups of 2 to 5 timers each, plus extra registers for capture/compare purposes. The TriCore and MACH architectures of microcontrollers have timer-coprocessors, which are more complex than a single 8051 microcontroller. So there are no "do's and dont's" fitting for all architectures you want to use.

Greetings, Axel

-------------------------------------------------- Für Antworten bitte ohne Punkt im Namen!

Reply to
Axel Farr

They are also functions that can be called from multiple threads. The situation being that it can interrupted in mid-execution in one thread, and be called from another. Both threads should still get their expected results when their respective calls to the function complete.

Rufus

Reply to
Rufus V. Smith

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.