<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>RTX51 and function calls</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/15707/rtx51-and-function-calls</link><description> Hi all, 
 
This is my second message on the issue to clarify the question. 
 
From the documentation: 
 
**************** 
Standart C51 functions must not be called simultaneously from several tasks or interrupt procedures. These functions store their</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: RTX51 and function calls</title><link>https://community.arm.com/thread/109857?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2001 17:20:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7dc289be-16d2-4a6d-a545-d96677371b8d</guid><dc:creator>Bahri Okuroglu</dc:creator><description>&lt;p&gt;Dear Ward,&lt;br /&gt;
&lt;br /&gt;
Following is a quotation from Andrew&amp;#39;s mail:&lt;br /&gt;
&lt;br /&gt;
*****************&lt;br /&gt;
calls. However, RTX51 Tiny does not contain any management for the C51 reentrant stack. If you are using 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 the Round-Robin task scheduling of RTX51 Tiny. The full version, RTX51 Full contains a stack management for reentrant functions.&lt;br /&gt;
*******************&lt;br /&gt;
&lt;br /&gt;
According to this, even with reentrant functions you CANNOT use task switching.&lt;br /&gt;
&lt;br /&gt;
In fact I have a PID routine which calculates and acts properly in an *infinite loop*. &lt;br /&gt;
&lt;br /&gt;
I want to call this function for different channels from 8 different task. This way, I can manage 8 different channels using a single PID routine. &lt;br /&gt;
&lt;br /&gt;
But the manuel says that I cannot use functions with task switching enabled.&lt;br /&gt;
&lt;br /&gt;
Am I wrong?&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTX51 and function calls</title><link>https://community.arm.com/thread/84130?ContentTypeID=1</link><pubDate>Fri, 27 Jul 2001 12:14:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9583dab9-c91c-4aa4-8e7d-6a5fc5261b8f</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;&lt;i&gt;Then where are the benefits of using RTX51?&lt;br /&gt;
&lt;br /&gt;
Cannot I use functions and RTX51 tiny together?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The only problem comes when you have a function that is called from more than 1 task.&lt;br /&gt;
&lt;br /&gt;
The problem is that since arguments and locals are stored in fixed memory locations, functions are no reentrant (by default).&lt;br /&gt;
&lt;br /&gt;
If you need reentrant functions, declare them as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
int function (arg_list) compact reentrant
{
}
&lt;/pre&gt;
&lt;br /&gt;
Then, you may call them from multiple tasks.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTX51 and function calls</title><link>https://community.arm.com/thread/53804?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2001 12:50:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f97ce7c0-4e9f-46c7-bbfc-3818cdc5b8b0</guid><dc:creator>Bahri Okuroglu</dc:creator><description>&lt;p&gt;Thank you for your kind reply and quotation. Yes, the quotation clarified the issue. &lt;br /&gt;
&lt;br /&gt;
According to the text;&lt;br /&gt;
&lt;br /&gt;
1. We cannot use non-reentrant &lt;br /&gt;
   functions from several tasks. C &lt;br /&gt;
   functions which only uses registers &lt;br /&gt;
   for parameters are inherently &lt;br /&gt;
   reentrant. &lt;br /&gt;
&lt;br /&gt;
   Then when task switching performed, &lt;br /&gt;
   registers are backed up to the &lt;br /&gt;
   system. Is this true?&lt;br /&gt;
&lt;br /&gt;
   Then how can I define a variable in &lt;br /&gt;
   register? I tried &amp;quot;register data &lt;br /&gt;
   int..&amp;quot;, but this did not work. &lt;br /&gt;
&lt;br /&gt;
2. When using reentrant functions, task &lt;br /&gt;
   switching should be disabled (for &lt;br /&gt;
   tiny). &lt;br /&gt;
&lt;br /&gt;
   Then where are the benefits of using &lt;br /&gt;
   RTX51?&lt;br /&gt;
&lt;br /&gt;
Cannot I use functions and RTX51 tiny &lt;br /&gt;
together?&lt;br /&gt;
&lt;br /&gt;
Thanks for reading...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTX51 and function calls</title><link>https://community.arm.com/thread/37726?ContentTypeID=1</link><pubDate>Tue, 24 Jul 2001 05:37:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:33d58241-dfe8-4e4b-bffb-fa614544dbb2</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;Which version do you have?&lt;br /&gt;
&lt;br /&gt;
Here is the text from the latest manual (v2.95):&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;It is not allowed to call non-reentrant  C functions from several tasks or interrupt proce-dures.&lt;br /&gt;
Non-reentrant C51 functions store their parameters and automatic variables (local data) in static memory segments; for this reason, this data is overwritten when multiple function calls occur simultaneously. Therefore non-reentrant C functions can only be call for several tasks, if the user can ensure that they are not called recursive. Usally this means that the Round-Robin task scheduling must be disabled and that such functions do not call any RTX51 Tiny system functions.&lt;br /&gt;
C functions which are only using registers for parameter and automatic variables are in-herently reentrant and can be called without any restrictions from different RTX51 Tiny&lt;br /&gt;
tasks.&lt;br /&gt;
The C51 Compiler provides also reentrant functions. Refer to the C51 User&amp;#39;s Manual for more information. Reentrant functions store their parameters and local data variables on&lt;br /&gt;
a reentrant stack and the data are protected in this way against multiple calls. However, RTX51 Tiny does not contain any management for the C51 reentrant stack. If you are using 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 the Round-Robin task scheduling of RTX51 Tiny. The full version, RTX51 Full contains a stack management for reentrant functions.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
dunno if that makes it any clearer!?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>