LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

same read from 2 threads

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 7
(3,901 Views)

Ciao Graziano,

if I get you right, you are willing to use the same DAQmx Task from 2 separate threads (ideally simultaneous). I am not sure this is possible.

DAQmx is multithreaded, so there is no problem in accessing the DAQmx Driver from 2 different threads at the same time in parallel.
The thing that sets me off is using the same Task (i.e. the same board resources) in 2 different places at the same time.
What do you mean by " I have poor means to test this" ?

You could put together a piece of software that tries to open the same task from 2 different threads on a device.

Could you post an example here?

AlessioD

0 Kudos
Message 2 of 7
(3,874 Views)
You might want to design your system to read the daq channel from only one of the threads or from it's own thread.  When a read occurs use a thread safe variable or a thread safe queue (or even a queue for each receiving thread) to pass the data along.  That way possible collisions will be minimized. 
Message 3 of 7
(3,871 Views)
Hi mvr,

  of course your solution is good, in common applications, I've thought too, but....
 
    I'm developing a driver. A 3-rd party application should call functions such as READ and WRITE (Read and write Digital values), and my driver should implement them.  More, the driver should have a thread that continuously "listen" upon 2 lines (to simulate  interrupts).   The easyest way is having 2 threads.  In this way I can perform "simultaneously" a READ DIGITAL IN function and  I can listen to the interrupt lines.
     
       Note: the application which calls these function is an old program running on an emulated PDP11!!!! So pdp11 emulator (running in Windows) has a standard interface to develop drivers for new PCI devices (my NI 6509) that should emulate older devices (DEC DRV11  parallel interface, produced by Digital).

   That's why I can't use your solution:  the 2 thread system can lead to not-acceptable timings  in I/O operation.

   I've posted my question in another NI board, and the answer was that I can  do it (2 reads from 2 threads). 
      look: http://forums.ni.com/ni/board/message?board.id=70&message.id=4451#M4451
  it's a NI answer!

  My best whish is to say "I love Digital and the glorious pdp11!".....


graziano



0 Kudos
Message 4 of 7
(3,868 Views)

Very interesting application.  Amazing that legacy PDP-11 code can be adapted to todays hardware.

Good Luck!

Message 5 of 7
(3,861 Views)
Hi mvr,
   thanks for your interest in this application!

   If you're looking to some infos....
   http://www.softresint.com/charon-11/

   pdp-11 was used in many industrial process-control tasks, and was considered reliable, partly due to good RT operating systems.

   Bye, and have a nice day!

graziano

0 Kudos
Message 6 of 7
(3,848 Views)
I think a PDP 11/44 was the first system I ever worked with.  A long time ago now.  I have not seen one in years, but got a real kick out of knowing that there is still some of that legacy code in use.  Thanks for the link.
0 Kudos
Message 7 of 7
(3,828 Views)