Subj : Re: pthreads: combine condvar and select To : comp.programming.threads From : Sean Burke Date : Wed Jan 12 2005 09:19 pm Bernhard Roessmann writes: > Phil Frisbie, Jr. wrote: > > You can create a loop-back UDP socket and add it to the other file > > handles. Then a second thread simply sends a small (or even zero length) > > UDP packet to 'wake up' the first thread. > > Hi Phil, > > or some other sort of unix "standard IPC" mechanism, I know. > But this seems to be much overhead for sending a little "event" to the thread. Compared to the cost of blocking in select and later waking from it and reading from the fd, the cost to write to a pipe or unix socket is going to be incremental. It doesn't make sense to worry about it, especially since there is no better alternative. > I'm amazed why pthreads "signaling" is not "select compatible", this would be > very nice an consistent. Yes, and also POSIX and SysV message queues, and async io completions, etc... Solaris 10 has a solution for this, which might eventually be standardized. > Anyway, seems that I have to use some of the heavier IPC mechanisms for this :-/ And, other threads in this group have shown that a pipe can be surprisingly performant, compared to the other supposedly "light-weight" mechanisms. > BTW: UDP is per definition "unreliable". But I think, UDP over a unix socket > should be reliable, right? You could also use a pipe. For inter-thread communication, you can just write pointers into it, rather than entire data structures. And you can set the (non)blocking mode at each end of the pipe separately, since you probably want the writer to block on a full pipe, while the read end should be nonblocking. -SEan .