From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4196 invoked by alias); 29 Oct 2003 15:33:26 -0000 Mailing-List: contact ecos-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@sources.redhat.com Received: (qmail 4188 invoked from network); 29 Oct 2003 15:33:25 -0000 Received: from unknown (HELO anchor-post-30.mail.demon.net) (194.217.242.88) by sources.redhat.com with SMTP; 29 Oct 2003 15:33:25 -0000 Received: from calivar.demon.co.uk ([212.228.213.211] helo=miso.calivar.com) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1AEsK3-0003TZ-0U; Wed, 29 Oct 2003 15:33:24 +0000 Received: from miso.calivar.com (miso.calivar.com [127.0.0.2]) by miso.calivar.com (Postfix) with ESMTP id 540D928DF45; Wed, 29 Oct 2003 14:55:42 +0000 (GMT) To: Dan Jakubiec Cc: ecos-discuss@sources.redhat.com References: <20031028210929.26334.qmail@web21208.mail.yahoo.com> From: Nick Garnett Date: Wed, 29 Oct 2003 15:33:00 -0000 In-Reply-To: <20031028210929.26334.qmail@web21208.mail.yahoo.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [ECOS] POSIX timer callback context X-SW-Source: 2003-10/txt/msg00491.txt.bz2 Dan Jakubiec writes: > I'm using a POSIX timer in my application that I > created with timer_create(). It is configured to > generate a SIGUSR1 signal when the timer expires, and > to call a signal handler installed by my app's thread. > I also have several different tasks running that were > all created with pthread_create(). > > When the timer expires, the signal handler gets > executed, but it appears to be executing in a another > thread's context (i.e. pthread_self() returns the > handle for one of my other threads). Furthermore, the > thread that installed the handler is waiting in a > pselect() call that never gets interrupted with EINTR. > > This seems like a bug to me, but I wanted to pass this > by the group before fixing it to make sure I wasn't > missing anything. Seems like there is a bit of a grey > area in the POSIX docs about whether signals get > delivered to the "process" or one of its "threads". > However, it seems that in eCos it would only make > sense to deliver signals to the calling thread itself. > > Does anyone have any background info on the eCos > implementation of POSIX timers, or an opinion on how > POSIX timer callbacks should be processed? This is not a bug. The POSIX spec is fairly clear that these are process-wide signals that will be delivered to any thread that has the signal unmasked. There are lots of problems with doing thread-specific signals here that the POSIX committee decided to avoid by side-stepping the problem. If you want to direct the signal to a specific thread then just make sure that that thread is the only one with the signal unmasked. The best way to ensure this is to mask it in the signal mask of main() before creating any other threads, which will then inherit main()'s mask, and unmask it in the target thread. -- Nick Garnett eCos Kernel Architect http://www.ecoscentric.com The eCos and RedBoot experts -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss