<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Reentrant code</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/</id><updated>2020-02-27T13:49:47.524000Z</updated><subtitle>Recent posts to Reentrant code</subtitle><entry><title>Reentrant code</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/?limit=25#6042" rel="alternate"/><published>2020-02-27T13:49:47.524000Z</published><updated>2020-02-27T13:49:47.524000Z</updated><author><name>rickj</name><uri>https://forge.codesys.com/u/rickj/</uri></author><id>https://forge.codesys.comc8d8014ab5efa445808923b2f54e5d982b861221</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Josep,&lt;/p&gt;
&lt;p&gt;Variables created within the scope of a method or function are dynamically created and destroyed with each invocation, making them reentrant.  Exceptions to this are variables declared in a VAR_STAT section and pointers or references to statically defined variables.  &lt;/p&gt;
&lt;p&gt;If a function or method recursively calls itself the compiler will complain about not being able to calculate stack usage but there is an attribute pragma that can be used to control/suppress the warning.  Presumably you know to limit call depth.&lt;/p&gt;
&lt;p&gt;Variables created within the scope of a FB or PROG are statically created an maintain their values between invocations.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Reentrant code</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/?limit=25#74c0" rel="alternate"/><published>2020-02-27T13:49:47.388000Z</published><updated>2020-02-27T13:49:47.388000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com9fb9df0551b9b3de1564c814d1066c21c312d4ca</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The question has two parts.&lt;/p&gt;
&lt;p&gt;One is to know if it is possible to use functions which can call himself (usefull when working with tree arrays for example)&lt;/p&gt;
&lt;p&gt;The other is that I m not sure if I could use the same function (system time functions like getSystemTimeNs, if there exist a copy of his local variables in each call it is possible that there not exist any problem) in a hard real time task and in a freewheel task.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Reentrant code</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/?limit=25#a1a1" rel="alternate"/><published>2020-02-27T13:49:47.256000Z</published><updated>2020-02-27T13:49:47.256000Z</updated><author><name>Joan M</name><uri>https://forge.codesys.com/u/joan-m/</uri></author><id>https://forge.codesys.com2e9263bf5ca355d595a26444844f3cd8a0be8c31</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Josep!&lt;/p&gt;
&lt;p&gt;That's an interesting question.&lt;/p&gt;
&lt;p&gt;There is TestAndSet in TwinCAT (I guess it is also in Codesys) which is used to block other tasks to access a code fragment... something along the lines of a critical section in C++.&lt;/p&gt;
&lt;p&gt;See:  l &lt;a class="" href="http://forum.codesys.com/viewtopic.php?t=5042" rel="nofollow"&gt;viewtopic.php?t=5042&lt;/a&gt; l &lt;/p&gt;
&lt;p&gt;They speak about CAA.TaskLock(); and CAA.TaskUnlock(); which look interesting.&lt;/p&gt;
&lt;p&gt;Probably looking for information about those functions will lead you to the main point of your question.&lt;/p&gt;
&lt;p&gt;Hope this helps even it is only a little.&lt;/p&gt;
&lt;p&gt;Good luck and please, post the answer if you find it!&lt;/p&gt;
&lt;p&gt;Best regards!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Reentrant code</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/e1e7340bf4/?limit=25#f088" rel="alternate"/><published>2020-02-27T13:49:47.120000Z</published><updated>2020-02-27T13:49:47.120000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.comea045ea381ba14ae9740cbb2553f405846a064c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Dears.&lt;/p&gt;
&lt;p&gt;Do you know if the local variables of a functions or methods are created everytime the funtion is called?&lt;/p&gt;
&lt;p&gt;That is, if I call a function from two diferent tasks simultaneously, or if I call a function from himself, every call has his own local variables created?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>