Fustercluck
Member
Hi,
My reading of the windows version of the the rawhid code (hid_WINDOWS.c) leaves me uncertain about whether rawhid_send() and rawhid_recv() are thread safe. I do see critical sections/mutexs, but enough global state that I wouldn't want to assume thread-safety.
So, question #1 is, Are these functions safe to call from multiple threads (where each thread manages IO to a specific device)?
Question #2 concerns whether there's any point if having multiple threads. Since there's a mutex surrounding blocking IO calls (in both send and recv functions), I would think that as soon as thread A grabs the mutex and then starts to wait for IO, all other threads will block if they call the same function--even if data were available immediately from their devices.
In other words, IO waiting in one thread for one device, will cause all threads to wait/block.
Do I have this correct?
Thanks,
Dan
My reading of the windows version of the the rawhid code (hid_WINDOWS.c) leaves me uncertain about whether rawhid_send() and rawhid_recv() are thread safe. I do see critical sections/mutexs, but enough global state that I wouldn't want to assume thread-safety.
So, question #1 is, Are these functions safe to call from multiple threads (where each thread manages IO to a specific device)?
Question #2 concerns whether there's any point if having multiple threads. Since there's a mutex surrounding blocking IO calls (in both send and recv functions), I would think that as soon as thread A grabs the mutex and then starts to wait for IO, all other threads will block if they call the same function--even if data were available immediately from their devices.
In other words, IO waiting in one thread for one device, will cause all threads to wait/block.
Do I have this correct?
Thanks,
Dan