|
From: Julian S. <js...@ac...> - 2009-02-06 19:19:37
|
Christoph, I understand, by reading the thread that Tom Fogal refers to .. > http://groups.google.com/group/comp.programming.threads/browse_thread/thread/ > 4f65535d6192aa50/a5f4bf1e3b437c4d?lnk=st&q=#a5f4bf1e3b437c4d .. that the POSIX pthreads standard is in a way broken: you cannot know when you are the last thread to leave the barrier, and so there is no safe way to destroy the barrier without using yet another synchronisation operation to somehow guarantee that all the threads really have left the barrier. That is a correct understanding, yes? Now it is indeed the case that both Helgrind and DRD do report destruction of a barrier which has waiting threads. You can easily verify this using the regression test case helgrind/tests/bad_bar.c. However, in your example, all threads are considered by Helgrind and DRD to have left the barrier before you destroy it. Hence no error is reported. If you can suggest some criteria that allows to distinguish the case you consider an error, from a "safe" destruction of a barrier, that would be very helpful. But given that the POSIX spec is basically broken, I don't see how it would be possible to construct such a criteria. J On Thursday 05 February 2009, Christoph Bartoschek wrote: > Am Donnerstag, 5. Februar 2009 schrieb tom fogal: > > I'm getting a bit off topic, but .. > > > > Perhaps I'm just not understanding the linked-to discussion, but given > > this interpretation -- how could one ever delete a barrier? > > > > It sounds like the only safe way to destroy the barrier is if you've > > joined every thread which could have possibly used it. Given that > > constraint, I'm not sure how real world software could reasonably deal > > with this. > > > > So is the idea essentially that we might as well forget about > > destroying barriers? What am I missing? > > 1. There is the proposal to fix the standard by allowing the thread that > gets the return value of PTHREAD_BARRIER_SERIAL_THREAD to destroy the > barrier. > > 2. You can delete the barrier as soon as you know that all threads left the > call to pthread_barrier_wait(). This can be done by other synchronisation > primitives like another barrier, a lock, a condvar or a join. > > Christoph > > --------------------------------------------------------------------------- >--- Create and Deploy Rich Internet Apps outside the browser with > Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing > skills and code to build responsive, highly engaging applications that > combine the power of local resources and data with the reach of the web. > Download the Adobe AIR SDK and Ajax docs to start building applications > today-http://p.sf.net/sfu/adobe-com > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users |