Subj : Re: thread control by mutex, predicates and conditions puzzle To : comp.programming.threads From : Jomu Date : Sat Jan 08 2005 03:47 am roland wrote: > Jomu wrote: > > > What is this stop/start action thing? Do you want to freeze your > > threads only at some points or wherever they happen to be when you stop > > them? > > Say, your thread is blocking on IO. Now an external thread that is in > charge of master control needs to tell: quit and restart IO. For I/O in threads, pthread_kill will probably do, as I/O operations are expected to return with EINTR (/me expects someone will correct me here if it is no always true, ie. portable). But, your I/O operations must learn this and handle EINTRs, of course. > But I do not want to cancel the entire thread! (Imagine I have other > valuable > state information in my thrad.) Of course not. > > How should I go for it when I > 1) want a single thread wide master control while still be able to > wait on different things during the threads lifetime Take a look at my garbage collector solution (link in other post), and pls tell me if ideas from there cover your needs. > 2) _and_ write code with portability in mind? (The IO clearly is > highly system dependant.) My mantra is "POSIX only" :). I do take a shortcut from time to time, of course, but always trying to play it safe. > > I would be very glad if you could point me to such a pattern, since > I am too a bit concerned of the "thundering herd" problem my broadcast > could cause. > > Roland dd .