Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Two instances of same actor run public methods synchronously

Solved!
Go to solution

I have two instances of an actor each controlling an identical piece of hardware. When troubleshooting with the DETT, I noticed that when the same message is sent to both instances, the second to receive the message does not call its public method until the first one has completely executed its public method (this is running emulation code in place of the hardware).

I have many other actors running in this application, so I was wondering if this behavior could be due simply to limitations with processor cores/threads?

0 Kudos
Message 1 of 5
(1,854 Views)
Solution
Accepted by topic author BillMe

It sounds like you have the public method set to non-reentrant. You can change this by setting the reetrancy to shared-clone or preallocated-clone mode in the VI settings.

 

https://zone.ni.com/reference/en-XX/help/372614J-01/lvconcepts/reentrancy/

0 Kudos
Message 2 of 5
(1,843 Views)

mbremer's answer sounds correct. Remember that you need to make the method VI be reentrant and also make any subVIs that it calls also be reentrant (unless they are short, incidental VIs and the minor thread friction doesn't bother your application).

0 Kudos
Message 3 of 5
(1,819 Views)

You are right. I assumed that the dynamic dispatch VIs were set to reentrant as is Actor Core. So for any actors for which I launch more than one instance, I will need to set all their methods reentrancy to "reentrant".

0 Kudos
Message 4 of 5
(1,815 Views)

@BillMe wrote:

You are right. I assumed that the dynamic dispatch VIs were set to reentrant as is Actor Core. So for any actors for which I launch more than one instance, I will need to set all their methods reentrancy to "reentrant".


Correct... if those methods are long-running and causing performance bottleneck. Remember that reentrancy is a space-vs-time tradeoff, which is why VIs are not reentrant by default. As a general rule, yes, you want more reentrancy in actors that are running in parallel with themselves, but I hesitate to say "always" because blind application of that rule can lead to bloated applications that lose performance on memory swaps. For small applications, doing "everything is reentrant" is fine.

0 Kudos
Message 5 of 5
(1,807 Views)