From owner-freebsd-questions Mon Oct 23 15:14: 4 2000 Delivered-To: freebsd-questions@freebsd.org Received: from imo-r06.mail.aol.com (imo-r06.mx.aol.com [152.163.225.6]) by hub.freebsd.org (Postfix) with ESMTP id 9186937B479 for ; Mon, 23 Oct 2000 15:13:58 -0700 (PDT) Received: from froekjaerf@netscape.net by imo-r06.mx.aol.com (mail_out_v28.32.) id n.1b.1cd13a (16232); Mon, 23 Oct 2000 18:13:54 -0400 (EDT) Received: from netscape.com (aimmail11.aim.aol.com [205.188.144.203]) by air-in02.mx.aol.com (v76_r1.8) with ESMTP; Mon, 23 Oct 2000 18:13:54 -0400 Date: Mon, 23 Oct 2000 18:13:53 -0400 From: froekjaerf@netscape.net (Flemming Froekjaer) To: freebsd-questions@freebsd.org Cc: bright@wintelcom.net Subject: Re: SIG codes > 128 allowed? Mime-Version: 1.0 Message-ID: <0963B774.2A753185.0F2A144B@netscape.net> References: <641C2F90.19430A3A.0F2A144B@netscape.net> <20001023130415.U28123@fw.wintelcom.net> X-Mailer: Franklin Webmailer 1.0 Content-Type: text/plain; charset="ISO-8859-1" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > > * Flemming Froekjaer [001023 12:35] wrote: > > In signal.h, more precisely the struct __siginfo, si_code is defined as an > > integer, but the same include file also defines the constant _SIG_MAXSIG, > > with a value of 128. Does this mean that FreeBSD won't allow signal codes > > above 128, or can you use the whole positive spectrum of an integer? > > > > The reason I ask is that I want to define a sighandler for every thread in a > > process. As you may know, threads share the parent process' signal handlers, > > so I'll need a unique signal code for each thread. I anticipate that the > > number of threads per process will be about a thousand. > > You'll want to find a better way to dispatch to each thread than to do > this.  You can use pthread_kill(3) to send a signal to a particular > thread. At first I thought I'd overlooked something, but after doing some research I've come to the conclusion that this still won't do it. You can send the signal to a particular thread, alright, but if more than one thread has unblocked that particular signal, it will subsequently be very difficult to determine which thread the signal was directed at. Furthermore, the process-level signal handler must block the signal in question while handling it. What I aim for is true thread-level asynchronous I/O. I want independant, event-driven threads, basically, where each thread has it's own signal handler which can be invoked, regardless of process states, at any given time. Now, if I can safely use signals outside the kernel-defined range, all my problems will be solved. I just assign a unique signal - and consequently a unique signal handler - to each thread. I'd love to use processes for this, but I'm afraid those are too costly for this application. The need for speed and all that... Again, thanks for all your help! \Flemming To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message