From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple read from a task+

Hi People!

   I'm developing an application dealing with digital I/O. I have two tasks, one for Input channels, one for outputs.  In my application I've also 2 threads

   my question is: can I perform a DAQmxReadDigitalU8() function, associated with the same task, (say, taskHanlder_1) form the 2 different thread? Can this cause collisions? I mean, if the 2 threads runs "simultaneously" (it is actually impossible, of course on a single processor system), and both perform Read function, what does it happen?

   I'm asking this because I've poor means to test this behaviour...

   Thanks!

graziano
0 Kudos
Message 1 of 3
(3,056 Views)
Hi Graziano,
 
Yes, the you can access the same task from two different threads at the same time.  The DAQmx driver will lock the task while the first thread is accessing it.  If the second thread tries to access the same task at the same time, it will wait until the first thread finishes and then, when the first thread unlocks the task, the second thread will be able to read from the task.  DAQmx ensures that the multi-threaded access is safe and will not cause a race condition.
 
 
 
Message 2 of 3
(3,046 Views)
Thank you, Jonathan,

 
your answqer is 100% clear!

  I've build my dll, and I experienced a system lock (about one C instruction per minute). This happened only once, maybe some lock due to shared resources..... I will chek better!

   Thanks again, and have a nice day!

graziano

0 Kudos
Message 3 of 3
(3,041 Views)