Subj : Re: help with basic multithreading in C on solaris To : comp.programming.threads From : roger.faulkner Date : Sat Feb 26 2005 09:05 am Winbatch wrote: > Hi, I'm trying to learn multithreading and it doesn't seem to be working for > me. I have a feeling it has to do with the fact that I'm writing to files > rather than to printf, but maybe not. Basically, I wanted to see if it > would be faster to write to 4 files at the same time (parallel) rather than > 4 in a row (serially). however, when my multithreaded code executes, it > seems to do them in order anyway (I expected to see Starting/Ending all > mixed rather than in order). Does anyone know what I'm doing wrong? (Note, > I also tried to do it with 4 different functions (ie, go, go1, go2, etc.., > but that didn't seem to fix it). What release of Solaris are you using? If Solaris 7 or less, you are using the old libthread. If Solaris 8, you are using the old libthread by default but the alternate libthread is available for use (which is the same as the only libthread in Solaris 9). You cannot be using Solaris 9 or 10 because what you report would not happen on these releases. If you create your threads with the PTHREAD_SCOPE_SYSTEM attribute (see the pthread_attr_setscope() man page), then you will get the behavior you want. Sorry for the non-obvious behavior of the old libthread. Roger Faulkner Sun Microsystems .