03-17-2014 03:49 AM
Hello all,
I rarely used async timers, but now I do need them.
They run in a separate thread, right ?
Meaning in some cases I need to use mutexes or critical sections ?
I don't remember seeing functionnality for those in CVI. I normally use the pthread library on Linux, so I don't know what you guys recommand in CVI.
Thanks.
Solved! Go to Solution.
03-17-2014 04:11 AM - edited 03-17-2014 04:12 AM
Hi,
The thing is, if you have multiple async timers, they all run in the same thread.
So you may somewhat lose its accuracy if you have many of them running at the same time.
(We have encountered this before)
As in all multithread scenarios you have to protect your global data from simultaneous access.
We have used Thread-safe variables (TSV) alot with success.
You may try them if you haven't before..
Regards,
03-17-2014 04:41 AM
In addition to ebalci notes, take a look at this documentation on multithreading:
CVI comes with a full set of instruments to exchange and protect data across threads: beyond TSV already mentioned by ebalci you can can count for example on locks and Thread Safe Queues.