Subj : Re: How to manage time-slicing in Pthreads programs? To : comp.programming.threads From : Joe Seigh Date : Mon Feb 21 2005 11:56 am On Mon, 21 Feb 2005 17:09:12 +0100, jd wrote: >> >> > What does it use for ^C and timers? How is the timer action executed? >> >> >> >> Most GUI's use event queues. Most of the synchonization api on > windows, >> >> unix, and java has timeout options. >> > >> > I don't thing that polling an event queue to find out if there was > SIGSEGV >> > is a very bright idea. >> >> That doesn't follow. > > It's not like I think that signals are a great way for introducing > asynchronicity in a single-threaded programs. But what to do with events > which generate SIGILL, SIGABRT, SIGFPE, SIGKILL, SIGSEGV, SIGTERM, SIGBUS > and possibly some more? Ignore or force OS to act always the same way (eg. > terminate with core dump)? They are not "GUI-events", which are like other > signals, SIGIO, SIGINT or, most noticeably, SIGUSR1. > > In fact it's more like a question - i'm programming only for unices, so I > don't know how it's done on other systems. > Well, maybe it is off-topic - but since I asked... :P > ^C is a keyboard event. Marcin's argument seems to be that since he isn't aware of any other mechanism in unix to notify a thread that such an event has occurred, and is in his view efficient, that therefore no such mechanism can exist. That's completely absurd as there are plenty of mechanisms that can be used for this purpose. All he's proved is that he isn't aware of them. You brought up a synchronous exception which is something completely different. Unix chose its signal mechanism as the method of notification. Unfortunately they're usually not very useful as you have to have the compiler and OS cooperate with the right information in siginfo pointing to an instruction that you can somehow relate to something you did in the program source. It's done. Some compilers are set up to trap certain arithmetic exceptions because that's the mechanism the hardware provides. SIGSEGV is difficult to use properly in a C program. Most people using it are using it wrong especially when they think they can recover from some error. It's on my list of things that indicate someone doesn't know what they're doing. Ditto for SIGILL and SIGBUS. The SIGKILL, etc are more examples of the asynchronous signaling. Same argument as ^C. It's not the only way you can do things. Every seems to be ignoring the obvious example of MS windows and other OSes that don't have signals and seem to be otherwise perfectly functional. -- Joe Seigh .