From: Igmar P. <mai...@jd...> - 2003-05-31 10:36:11
|
On Fri, 29 May 2003, Jeremy Fitzhardinge wrote: > They're already useless for that; I'm guessing you really want to be > using condition variables, which have the behaviour you're looking for. > With any luck, they synchronization code is only in one or two places... I don't agree, they're used to protect global variables from having multiple threads messing with then : pthread_mutex_lock(&mutex); for (....;...;...) { /* Walk linked list*/ ..... } pthread_mutex_unlock(&mutex); This works fine, at least in my app with at least 5 threads running, not counting incoming connections. I use rwlocks whenever I can, that means you must be able to read a datastructure without modifying it. cond. variables are the way to go when it comes to thread synchronisation, I use them to process an application shutdown. I've seen weird things happening when valgrind monitors threads, including the SIGFPE's flying around :). I'll see if I can reproduce it again, I know what happened when those things started. > > > The bug is that Valgrind should flag this as an error. > > > > The whole cinelerra (quite a huge program) is based upon this kind of > > behaviour. It uses mutexes in order to synchronize 'data delivery': > > That's exactly what a condvar is for. Indeed. Mutexes can't be used for that. > > So my question is... would it be possible for Valgrind to support this > > bugous behaviour by some switch or something? > > If you come up with a patch we can look at it. But I think your time > would be better spent fixing the code: what you're asking is equivalent > to "but my program always uses memory after it has been freed, and it > works fine without Valgrind". > > > The problem is that cinelerra works just fine if it is run without > > valgrind... > > Oh yes. Have you tried it with NPTL? That requires kernel patching and a complete glibc rebuild :) Just to wonder OT : Can both LinuxThreads and NTPL be build into the same glibc ?? > > J Igmar |