LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MATLAB multithreading

Does anyone know if the matlab script vi will play nice in a multithreaded application and actually multithread or if it will run until completion?
0 Kudos
Message 1 of 4
(5,754 Views)
LabVIEW is multithreaded and it handles the threading of VIs automatically. The bigger issue is whether the Matlab script node can run in its own thread (reenterant) will run in the user interface thread. I would bet money on the latter situation is the case because there are certain criteral that must be met to have thread safe code such as not accessing global resources. The most important rule is that thread safe code cannot call other code that is not thead safe. Since the Matab script node calls Matlab via activeX and NI does not know the thread safeness of Matlab, I stongly suspect that LabVIEW forces the Matlab Script Node to run in the User Interface thread (the safest choice).
Message 2 of 4
(5,753 Views)
Matlab is NOT multithreaded. As of version 6.5 it is possible to use the timer functions to simulate thread events..
When running as a automation server, matlab is a multithreaded singe object - ie all 'activex / com' calls are executed in a single object - single thread. The order of excution is based on the order of commands arriving - new incoming commands will block / wait until the existing ones have completed execution. The timer function can override this though callbacks.
Another alternative is to open matlab with the command line matlab.application.single . This approach creates multiple single objects - but there is no data sharing. It is like creating two seperate matlab sessions. However this functionality is not supported by AutomationOpen functions in L
abview - although I have asked for it. If it interests you, please send a request and we might get it as a feature in future released. Basically rather than a drop down list of ActiveX type library ID's it would be better to have a 'constant' text input.
Marc
Ps if you want more help let me know as ive done a bit of Labview/Matlab event parsing.
Message 3 of 4
(5,758 Views)
> Ps if you want more help let me know as ive done a bit of Labview/Matlab event parsing.
 
I have a similar problem, I need to call simultaneously several methods of a Matlab Run-Time (MCR) Executable from LabVIEW, but the ActiveX Server doesn't process a method until it finishes the previous.
 
Is there already any solution? As far as LV 7.1.1 is concerned, it still seems impossible to open different instances of the MCR.
 
Regards,
Aitor
0 Kudos
Message 4 of 4
(5,613 Views)