Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Why can't launch nested actor be used in Pre Launch Init?

I'm just trying to understand (without spending a day buried in the actor framework vi's) why nested actors can't be started in pre launch init. The help says only to launch nested actors from actor core. In looking at where pre launch init is called (part of actor.vi), it's just before actor core is started. What is the difference between launching a nested actor here vs first thing in actor core?

From the help:

Caution  Do not use the Pre Launch Init method to call the Launch Root Actor method. Doing so causes this method to hang. Use only the Launch Nested Actor VI from the Actor Core method.

For that matter, what mechanism prevents launching root actor inside pre launch init? Not that I'm trying to do that, but it's not immediatly obvious why the method would hang.

0 Kudos
Message 1 of 8
(5,136 Views)

Pre-Launch Init happens, as the name implies, before the newly instantiated Actor is finished launching.  Launch Root Actor is non-reentrant, and waits for the new Actor to finish launching so it can return the Actor's enqueuer.  An Actor unable to finish launching until it has launched others induces deadlock on the Launch Root Actor function.

wrkcrw00 wrote:

In looking at where pre launch init is called (part of actor.vi), it's just before actor core is started. What is the difference between launching a nested actor here vs first thing in actor core?

Below is what is happening in Actor.vi.  Launch Root Actor creates a new clone of this VI, runs it, and waits for it to return the enqueuer.  The difference between launching a nested actor in Pre Launch Init vs Actor Core is that Pre Launch Init happens just before the Actor returns its enqueuer.  Since Launch Root Actor is still waiting for Actor.vi to return the enqueuer, any calls to Launch Root Actor (which is non-reentrant, remember) before Actor.vi does so will result in deadlock.  Actor Core runs just after the Actor returns its enqueuer, which means Launch Root Actor is able to run without deadlock.

actor.JPG

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 2 of 8
(4,400 Views)

Ok, I see it now. Actor.vi sends the enqueuer back to launch actor core via the queue of queues, where launch actor core is sitting waiting for it. Hence a non re-entrant vi holds up any new actors from being launched.

Since both launch nested and launch root use the same launch actor core.vi, both would cause a hang if used in pre launch init. The help notes make a distinction between root and nested which led to my question. I realize it does say to use actor core.vi to launch nested actors only. Might be prudent to update the first sentence of the help to say something like "Do not use the Pre Launch Init method to launch any other actor, root or nested".

0 Kudos
Message 3 of 8
(4,400 Views)

wrkcrw00: You should see that note in the help for Pre-Launch Init.vi. If you do not, please let me know.

0 Kudos
Message 4 of 8
(4,400 Views)

It also notes that this design of Pre Launch Init.vi is deliberate to provide a mutual exclusion zone where you know for certain that no other actor can be attempting to acquire resources at the same time.

0 Kudos
Message 5 of 8
(4,400 Views)

My only comment on the help was on this statement:

Caution  Do not use the Pre Launch Init method to call the Launch Root Actor method. Doing so causes this method to hang. Use only the Launch Nested Actor VI from the Actor Core method.

Where it specifically says don't use "Launch Root Actor". I was wondering why it didn't say don't use "Launch Root Actor" or "Launch Nested Actor". I get that the 2nd sentence specifies where launch nested should be used, but I'm an engineer and when I see something that says explicitly "don't do this" but only lists one of the two options, I immediately wonder about the 2nd option.

No need to make an update on my behalf. It's pretty clear from the help where launching needs to take place. I was trying to sort out why.

0 Kudos
Message 6 of 8
(4,400 Views)

AH. Good catch! That should mention both launches. Someone edited it when we depricated the lone "Launch Actor.vi".

0 Kudos
Message 7 of 8
(4,400 Views)

This still hasn't been fixed (as of LabVIEW 2017). It confused me as well, as I knew that you can't launch any actor in Pre Launch Init but this wording seemed to imply otherwise.

0 Kudos
Message 8 of 8
(3,755 Views)