Subj : Re: help with basic multithreading in C on solaris To : comp.programming.threads From : Leon Mergen Date : Sat Feb 26 2005 05:41 pm On Sat, 2005-02-26 at 15:58 +0000, Winbatch wrote: > "Leon Mergen" wrote in message > news:1109433856.3938.9.camel@localhost.localdomain... > > On Sat, 2005-02-26 at 15:14 +0000, Winbatch wrote: > >> 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). > > > > Since writing to files uses functions which might block, this is indeed > > true, provided that you don't take thread initialization into account > > (use a thread pool, for example). > > > > > >> 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). > > > > I haven't got any experience with C pthreads (i'm using C++ > > boost::threads personally), but could it perhaps be that the time to > > initialize a thread is longer than to actually execute the thread's > > function, thus resulting in an ordered list of start/end calls ? > > > > Regards, > > > > Leon Mergen > > > > I got the printouts about starting the threads immediately, so I don't think > initialization takes a long time.. (unless I misunderstand you). 'Immediately'... are you sure ? I mean, files get written to 'immediately' too... perhaps writing to a file takes 0.001ms, while initializing a thread takes 0.0015ms ... > I would > prefer to do multithreading in C++ rather than C, but all the resources I > found seem to use C multithreading. Do most people use boost or is there > something more 'out of the box/standard to C++'? Threads are not a part of C or C++, they're operating system specific implementations. So there is no out of the box standard... However, threads as they exist in boost are really easy to use. I've once written a test case, you can download it at http://solatis2.student.utwente.nl/thread.tar.gz .... hope this helps you out. Regards, Leon Mergen .