Hi Jailbait,
Thanks for the reply. However, I am very familiar with mutexes, semaphores and race conditions. In the code I am executing I havent used any mutexes or defined any critical sections yet.
Why no critical sections yet? Only, because I know the execution process to be linear right now. I mean that the initial thread initializes and makes some calls on the hal context. Then it creates thread 2, and thread 2 tries to make some hal calls but locks. Going back to thread 1, after it starts thread 2, it does call hal_dispatch(), which may be my source of contention. I am going to remove this call temporarily to see what happens. I have a few other ideas to test the behavior of hal api too.
The real problem though, is that I cannot create more than a single hal context to make calls on. Without this, I will be left to serializing all hal calls, yuk. My application is something like a web server. The user defines how many worker threads there are, and the application queues requests/jobs to each of the worker threads. Ideally, each worker thread would have a hal context.
I find the hal documentation lacking on multi-threading implementation. Really, hal documentation amounts to simple doxygen output of the embedded source comments. Figuring out hal this far has been very easy, mostly self explanatory, except no mention of multi-threading.
Also, another example of lacking hal docs, what is the hal main-loop integration callback? Ok, obviously somehow it helps you implement your application main loop and probably dispatching. But how? no sample, or further descriptions beyond the canonical...and I have looked REAL HARD!
My experience with programming is pretty extensive. I am comfortable with programming backend services, protocols, and linux device drivers. I've also made hardware peripheral cards using FPGAs and CPLDs. So it's ok to get real technical on me! (some of this is on my website.)
Thanks again,
Colin
Quote:
Originally Posted by jailbait
You describe your problem in terms of the order that various functions are called. A much better way to analyze the problem is to describe what mutexes are locked and in what order.
|