LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing context switching between Labview threads

Hello,

 

 I have 2 threads interfacing with 2 serial ports on Labview ( Lets say Thread1 , is responsible for polling COM1 and Thread2 for polling COM2 ).

By using occurrences, Thread1 executes before Thread2 and context switching is done according to Labview between the threads. Now, I'm looking to do the following :

 

As soon as a specific block of code is executed in Thread1, I need Labview to force context switching to execute Thread2. I want to do this in order to synchronize the data received from the 2 threads.

 

1- So, can this be done, or are there other ways for synchronization ?

2- What if I want Labview to run as a real-time process or a higher priority thread on Windows XP in order to emulate the real-time effect on a Windows XP and not get any delays ? ( I already changed the process priority from the Process explorer, but there seems no effect. I also changed the Labview threads priority to real-time)

3- Are there better approached for (1) & (2) ?  

 

Thank you,

  Walid F. Abdelfatah 

0 Kudos
Message 1 of 4
(2,500 Views)

Code thread Two to wait on an occurence and in thread One fire the Occurnece.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 4
(2,499 Views)

I already used occurrences for Thread1 to execute before Thread2. Does occurrences guarantee that Labview will switch the context to Thread2, as soon as the occurrence is fired ?

 

-- Walid 

Message Edited by wfarid on 02-12-2010 09:47 AM
0 Kudos
Message 3 of 4
(2,494 Views)

wfarid wrote:

I already used occurrences for Thread1 to execute before Thread2. Does occurrences guarantee that Labview will switch the context to Thread2, as soon as the context is fired ?

 

-- Walid 


 

NO!

 

LV depends on the OS to schedule threads. If you are sticking with Non-RT then you would be better off getting thread one to do the work while it has teh CPU.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 4
(2,492 Views)