07-03-2013 07:40 AM
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.
Solved! Go to Solution.
07-04-2013 04:36 AM
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/
07-04-2013 08:42 AM
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