From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI FPGA Interface C API multithreading safe?

Solved!
Go to solution

Hello,

 

I am using the FPGA interface C API to communicate with the labview software running on my NI FPGA. Some calls take quite some time to execute, e.g. reading from a FIFO when setting a long time-out. Up till now, I have been assuming that the interface was not multithreading safe. This has now become bothersome given the time-out issue described above. Simply trying does not feel right, it may take quite some time to create a 'collison'.

 

Is the FPGA interface C API multithreading safe? Or, more specifically, can FIFO reading-related functions be called in parellel with writing/reading of variables on the FPGA?

 

Thanks.

0 Kudos
Message 1 of 3
(2,710 Views)
Solution
Accepted by topic author MKAP

Hello MKAP,

 

It has been a while since I have used the NI FPGA Interface C API, but this is what I remember and seem to be able to recollect (and also found back in documentation):

 

The functions related to the unloading and loading of the library are not thread safe:

http://zone.ni.com/reference/en-XX/help/372928D-01/capi/functions_required/

 

On itself this should not cause a problem:

You application should force that the NiFpga_Initialize is called before all other function NIFpga related function calls.

In a similar way the unloading (NiFpga_Initialize) lof the NiFpga brary should only happen when you're done using it.

 

Regarding multithreading you should also keep in mind the single-threaded character of IRQ  Interrupts (If you plan to use them):

http://zone.ni.com/reference/en-XX/help/372928D-01/capi/functions_interrupt/

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 2 of 3
(2,689 Views)

Hello Thierry,

 

Your answer seems right. After posting my question I searched the API help file for 'thread' and found a few functions that were reported as unsafe with respect to multi-threading. This implies/seems to imply the rest is multi-threading safe. And indeed the IRQ contexts are the multi-threading unsafe ones one needs to be careful with.

 

Thanks and best regards,

 

Maarten van Kampen

0 Kudos
Message 3 of 3
(2,682 Views)