Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What means reetrant code?

Status
Not open for further replies.

leomecma

Full Member level 5
Joined
Jun 17, 2005
Messages
244
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Location
Brasil
Activity points
3,933
reentrant code provides for

What means reetrant code in ANSI C?

leomecma
 

reentrant code

Found with Google search:
http://www.avocetsystems.com/company/articles/magazine/areentra.htm

A routine must satisfy the following conditions to be reentrant:

It never modifies itself. That is, the instructions of the program are never changed. Period. Under any circumstances. Far too many embedded systems still violate this cardinal rule. Any variables changed by the routine must be allocated to a particular "instance" of the function's invocation. Thus, if reentrant function FOO is called by three different functions, then FOO's data must be stored in three different areas of RAM.



The ANSI C Standard says:

The functions in the standard library are not guaranteed to be reentrant and may modify objects with static storage duration. Thus, a signal handler cannot, in general, call standard library functions.
 

    leomecma

    Points: 2
    Helpful Answer Positive Rating
write reentrant code

Briefly it means a procedure, which can be interrupted and again called from the interruption handler and this can be nested.
Varuzhan
 

what means code

Reentrant code makes extensive use of semaphores. Whenever the control enters a code section where some global variable is modified, code should first take the semaphore before modifying and after it's done should restore the variable to appropriate value and then release the semaphore.

Basicallt reentrant code should try to use local variables as much as it can.
 

is the standard function printf reentrant?

In simple it means,
A function is reentrant if, while it is being executed, it can be re-invoked by itself, or by any other routine, by interrupting the present execution for a while.

There are few thumbrules which you can find out through google

Cheers
idlebrain
 

printf is a reentrant function?

Dear all,
I'm trying RTOS for 8051, but I have problem with term “Reentrant Functions” in RTX51 Tiny. I don’t understand this term, so could anybody help and tell me the difference between “Reentrant Functions” and others functions c.
Here is the context of “Reentrant Functions” support by Keil.

"The C51 Compiler provides support for reentrant functions. Reentrant functions store parameters and local variables on a reentrant stack. This protects them from recursive or simultaneous calls. RTX51 Tiny does not contain any management for the C51 reentrant stack. So, if you use reentrant functions in your application, you must ensure that these functions do not call any RTX51 Tiny system functions and that reentrant functions are not interrupted by round-robin task switching.
C functions, which use only registers for parameter and automatic variables, are inherently reentrant and may be called without any restrictions from RTX51 Tiny.
Non-reentrant C functions may not be called from more than one task or interrupt procedure. Non-reentrant C51 functions store their parameters and automatic variables (local data) in static memory segments which may be overwritten when the function is called from multiple tasks simultaneously or recursively.
You may invoke non-reentrant functions from multiple tasks if you ensure that they are not called recursively (simultaneously). Usually this means that round-robin task scheduling must be disabled and that your non-reentrant functions may not call any RTX51 Tiny system functions.
Note
• You should disable Round-Robin Task Switching if you wish to invoke reentrant or non-reentrant function from more than one task or interrupt.
"
Thanks for yours help,
Best regards,
 

wrint reentrant functions

Reentrant code is code that can be called by any number of threads, even the same thread. Basically, each time a thread calls the routine it gets a pointer to its own set of data (except static data I would assume). You can imagine the problems that would occur if several threads called the same routine and all of them acted on the same set of data. The alternative is data locking which is not much of an alternative.
 

reetrant code

Hi all,
My question is how to write a reentrant function and ? of course,it's differ from normal functions, but how?
a typical function:
void hello(void)
{
int x;
x=835;
.........
printf(x);
printf("Hello everybody!");
}
and the reentrant function would be:
????
????
????
Thank for your replies
best regards,
 

reetrant

Refers to s/w ( a function ) that can be executed multiple times
simultaneously.
A reentrant function can be safely called from multiple tasks.
 

how to write reentrant code

haha,
good for nothing :D
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top