Keil Logo

reentrant RTX51 Tiny

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Klaus Wang
Posted
5-Jan-2007 09:15 GMT
Toolset
C51
New! reentrant RTX51 Tiny

This is a question about reentrant functions in RTX51 Tiny System.
AS follows articles I found in http://www.keil.com/support/man/docs/tr51/tr51_reentrant.htm:
" You should disable Round-Robin Task Switching if you wish to invoke reentrant or non-reentrant function from more than one task or interrupt. "

If I want to invoke either reentrant functions or non-reentrant functions in RTX51 Tiny system, and they will be called in one more tasks, I should DISABLE Round-Robin Task Switching in CONF_TNY.A51.

Is it right?

Another question is that: addition, subtraction, multiplication, division in C51 library, are they all reentrant functions? Any I should be careful when I use them in one more tasks of RTX51 Tiny system?

Read-Only
Author
ninja Z
Posted
5-Jan-2007 12:11 GMT
Toolset
C51
New! RE: reentrant RTX51 Tiny

Is it right?
Yes.

Another question...

C functions, which use only registers for parameter and automatic variables, are inherently reentrant and may be called without any restrictions from RTX51 Tiny.

Read-Only
Author
Andy Neil
Posted
5-Jan-2007 12:20 GMT
Toolset
C51
New! False assumption

"C functions, which use only registers for parameter and automatic variables, are inherently reentrant"

No, they are not!

Read-Only
Author
Reinhard Keil
Posted
5-Jan-2007 14:19 GMT
Toolset
C51
New! RE: False assumption

http://www.keil.com/support/docs/1861.htm

Read-Only
Author
Andy Neil
Posted
5-Jan-2007 15:57 GMT
Toolset
C51
New! RE: Important assumption

http://www.keil.com/support/docs/1861.htm says:

"If we create a function that only uses registers (and no fixed memory locations for variables), then we can rely on the ISR to save and restore the registers used. And, the function will be reentrant." (my emphasis)

So the function itself is not inherently reentrant - it is only reentrant when called via an interrupt that saves the registers

Does the same apply when calling from different RTX-51 tasks?

"As long as an interrupt saves these registers, this function may be reentered."

Does this hold if the ISR specifies the 'using' keyword...?

"Register banks are useful when processing interrupts or when using a real-time operating system because the MCU can switch to a different register bank for a task or interrupt rather than saving all 8 registers on the stack."
http://www.keil.com/support/man/docs/c51/c51_le_regbankspec.htm

See also: http://www.keil.com/forum/docs/thread8128.asp

Read-Only
Author
Reinhard Keil
Posted
8-Jan-2007 16:59 GMT
Toolset
C51
New! RE: Important assumption

Yes it is also valid for RTX51 or RTX51 Tiny tasks.

Read-Only
Author
Klaus Wang
Posted
9-Jan-2007 03:37 GMT
Toolset
C51
New! RE: reentrant RTX51 Tiny

Thank you guys for the useful information.
Right now I know that if I want to make sure functions can be called by one more tasks simultaneouslly, I should declare it with reentrant keyword.
Another test is that I create 2 functions as follows:

void test1(void) {
  unsigned char tmp1, tmp2;
  tmp1 = 10;
  tmp2 = 8;
}

void test2(void) {
  unsigned char tmp1, tmp2;
  tmp1 = 10;
  tmp2 = 8;
  tmp2 = tmp1/tmp2;
}


I found that a WARNING message occur while building target with test1(), the message is MULTIPLE CALL TO SEGMENT. But I can build with test2() sucessfully.
I know that whatever test1() or test2() all have overlay data group in *.M51. But I don't know what is the difference between test1() and test2().
Could you explain why the warning message occur?

Read-Only
Author
Reinhard Keil
Posted
9-Jan-2007 06:50 GMT
Toolset
C51
New! RE: reentrant RTX51 Tiny

In test1 the variables are not used (the program does notthing useful) and therefore the optimizer does not analyse variable life-times which results in un-optimized code.

You really need a program that does something with the variables that you define.

Read-Only
Author
Klaus Wang
Posted
10-Jan-2007 03:17 GMT
Toolset
C51
New! RE: reentrant RTX51 Tiny

Thank you, I understand that you said, but I don't know why warning message showing "MULTIPLE CALL TO SEGMENT"?

Because there are variables unused and make optimizer can't do optimal code, so cause this warning message?

So, if it was true, the message really makes me confused.

Read-Only
Author
Reinhard Keil
Posted
12-Jan-2007 07:28 GMT
Toolset
C51
New! RE: reentrant RTX51 Tiny

This is why we have a support knowledgebase that you can search:

"MULTIPLE CALL TO SEGMENT"

brings you to:

http://www.keil.com/support/docs/2042.htm

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.