Subj : Re: thread suspend using pthreads? To : comp.programming.threads From : Joe Seigh Date : Thu Sep 01 2005 09:12 am Yaytay wrote: > "Steve Watt" wrote in message > news:df65m7$2g24$1@wattres.Watt.COM... > >>So what is suspend/resume being used for in the application? >> >>There _are_ a few places where it's a useful feature. They are >>extremely rare. > > > On Windows it is reasonably common practice to start a thread suspended, > then resume it. > This does not introduce race conditions. > So I'd argue that it is suspend that is risky, not resume. > This is a way of dealing with the creation of threads being expensive so you create them before you actually need them. There are lots of ways of dealing with that. One is to use a condition variable or semaphore that the created thread blocks on first thing. You unblock it when you want the thread to actually start. Thread pools are a generalization of this mechanism. You prestart a bunch of threads and start them when you want to. You also can reuse the threads in this case. The other thing you can do when porting this code over is change the thread create to a no-op and make the thread resume the actual thread create (pthread_create). This won't affect correctness, just performance. Is there an actual performance issue on thread creation here? -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .