LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubRoutine vs Notifier

I'm currently working on an application and I need a way of managing errors across several threads.

 

The current decision I'm attemping to reach is which structure would be the correct to use for my application. The process works like a simple producer/consumer loop, with the exception that multiple items will not get queued (since an error that cannot be handle will be sent to the error reporting thread), and an error that can be handled is just sent as no error.

 

So my current decision falls to a notifier vs a subroutine. I'm on the fense about which would be the proper one to use. Time is very critical since this will execute on the communication thread (which generally needs to execute as fast as possible).

What I'm in the dark about is how a notifier and subroutine fully work. The questions I sort of need answered are.

 

1) Does the read operation of a notifier block? If so is it only when another thread is writing?

 

2) I know a subroutine blocks until it is no longer being called elsewhere. But does it execute if it is not being called elsewhere? I do not what one to end up consuming to much CPU time.

0 Kudos
Message 1 of 6
(2,389 Views)

@Valarauca wrote:

I'm currently working on an application and I need a way of managing errors across several threads.

 

The current decision I'm attemping to reach is which structure would be the correct to use for my application. The process works like a simple producer/consumer loop, with the exception that multiple items will not get queued (since an error that cannot be handle will be sent to the error reporting thread), and an error that can be handled is just sent as no error.

 

So my current decision falls to a notifier vs a subroutine. I'm on the fense about which would be the proper one to use. Time is very critical since this will execute on the communication thread (which generally needs to execute as fast as possible).

What I'm in the dark about is how a notifier and subroutine fully work. The questions I sort of need answered are.

 

1) Does the read operation of a notifier block? If so is it only when another thread is writing?

 

2) I know a subroutine blocks until it is no longer being called elsewhere. But does it execute if it is not being called elsewhere? I do not what one to end up consuming to much CPU time.


Something is comming across as "subroutine."  Do you, perhaps, have a spellcheck that is auto-correcting "subvi?"

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 6
(2,359 Views)

Hello Valarauca,

 

1) Yes, Notifiers are blocking.  I tend to think of them as single-element multicast queues, if that analogy assists in any way. The notifier API provides options for skipping "old" notifications that arrived before the wait as well as timeouts and status checks.

 

2) SubVIs set to subroutine have the option to skip execution if the VI would otherwise block.  If you have this enabled, they will not block - the subroutine subVI will return default values and the "skpped" Boolean will return true.  I think this is the option you are referring to, there is a bit more information in the LabVIEW help:

 

-Edit-  As I often do, I went and messed with subroutines after thinking about them while posting.  The "skipped" Boolean I referred to doesn't actually appear to be a fixture of the subroutine VI, just something I've seen and used several times.  Implementing this check is straightforward- all you need to do is create an output Boolean with an indicator value of True and a False constant wired to it in the Block Diagram.  If the VI is skipped, it will return the default value of the indicator.  In all other cases, it'll return False as specified by the constant.

 

LabVIEW Help: Prioritizing Parallel Tasks (see Subroutine Priority Level)

http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/prioritizing_parallel_tasks/#Subroutin...

 

Regards,

Tom L.
0 Kudos
Message 3 of 6
(2,351 Views)

@0utlaw wrote:

Hello Valarauca,

 

1) Yes, Notifiers are blocking.  I tend to think of them as single-element multicast queues, if that analogy assists in any way. The notifier API provides options for skipping "old" notifications that arrived before the wait as well as timeouts and status checks.

 

2) SubVIs set to subroutine have the option to skip execution if the VI would otherwise block.  If you have this enabled, they will not block - the subroutine subVI will return default values and the "skpped" boolean will return true.  I think this is the option you are referring to, there is a bit more information in the LabVIEW help:

 

LabVIEW Help: Prioritizing Parallel Tasks (see Subroutine Priority Level)

http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/prioritizing_parallel_tasks/#Subroutin...

 

Regards,


Hey, that's pretty good - I never thought to use that subVI option before, so that was the last thing that would come to mind for me.  I tip my hat to you!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 6
(2,346 Views)

Also, while searching I came across one of Darren's nuggets that has a pretty good discussion of subroutines.  Hope it's helpful!

 

Darren's Nugget 3.1.2010: Subroutine priority setting on VIs

http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-03-01-2010/m-p/1081505

 

Regards,

Tom L.
Message 5 of 6
(2,340 Views)

@0utlaw wrote:

Also, while searching I came across one of Darren's nuggets that has a pretty good discussion of subroutines.  Hope it's helpful!

 

Darren's Nugget 3.1.2010: Subroutine priority setting on VIs

http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-03-01-2010/m-p/1081505

 

Regards,


I'm sorry about hijacking this thread, but I just wanted to thank you for that tidbit of info.  (Also thanked with a kudo.)  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(2,337 Views)