> I have the same issue with our own message queues.
> Helgrind does not support them out of the box but can be easily enhanced.
>
> I did it with the help of source code changes:
>
> void Put(T elem) { // put() method of your queue
>   sem_t *uniq_sem = new sem_t;
>   sem_init(uniq_sem);
>   sem_post(uniq_sem);
>   // now do the actual 'put' stuff, putting uniq_sem together with elem
> }
>
> T Get() { // get() method of your queue
>   // do the actual 'get' stuff; get uniq_sem from queue together with elem
>   sem_wait(uniq_sem);
>   sem_destroy(uniq_sem);
>   delete uniq_sem;
>   return elem;
> }

Yes.  That is a good place to start; I also did some stuff like that.
Note that the initial value of the semaphore is zero.  Also, use
semaphores and avoid condition variables -- see
http://www.valgrind.org/docs/manual/hg-manual.html#hg-manual.effective-use
point (3.) for reasons why.

> The good thing is that you don't really need to create a real semaphore --
> just create a integer with unique value (I use atomic_increment of static
> var) and pass it to appropriate helgrind's user requests (see helgrind.h
> and hg_intercepts.c).

Better to just be simple and use sem_* functions.

J

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to