5cb Subj : Re: threads do not get cpa To : comp.programming.threads,comp.sys.sgi.misc From : Joe Seigh Date : Mon Aug 08 2005 08:40 am Jedrzej Dudkiewicz wrote: >>Could be lock contention from either the locks in your program or ones >>in a routine you are calling. Also if you were running Linux I'd >>suspect Linux's brain damaged signaling but you're using IRIX which >>I don't know if it has the same problem. > > > Why are they brain damaged? Where can I read about it? Just asking. > pthread_cond_signal|broadcast preempts the calling thread. That can slow things down considerably. For example, a simple producer/consumer file copy gets slowed down by 2x or 3x or so. There was a kernel patch floating around to "fix" this. Or you could use fastcv from http://sourceforge.net/projects/atomic-ptr-plus/ which is what I used. Or you could use a sem_trywait/sem_wait and do a sched_yield if you had to wait using sem_wait. In practice this means that doing the pthread_cond_signal after releasing the mutex, instead of while holding the mutex, has some performance benefits on Linux since the signaled thread will attempt to get the mutex before the signaler has a chance to release it if it is holding the lock while signaling. Both forms of signaling are correct but the former seems to upset some Posix purists for some reason. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. . 0