Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Jan 2004 08:26:34 +0800
From:      David Xu <davidxu@freebsd.org>
To:        Daniel Eischen <eischen@vigrid.com>
Cc:        arch@freebsd.org
Subject:   Re: sigaltstack with threads
Message-ID:  <3FF4BABA.5000601@freebsd.org>
In-Reply-To: <Pine.GSO.4.10.10401011138130.18629-100000@pcnet5.pcnet.com>
References:  <Pine.GSO.4.10.10401011138130.18629-100000@pcnet5.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Daniel Eischen wrote:
> On Thu, 1 Jan 2004, David Xu wrote:
> 
> 
>>Doug Rabson wrote:
>>
>>>I think that if its supported at all in threaded programs, it must be
>>>per-thread state otherwise you can't prevent two different threads
>>>colliding on the same signal stack. I can't quite see how this maps to
>>>KSE/KSEG since I only have the most hazy model of that stuff in my head
>>>right now.
>>>
>>>Anyway, I've worked around things by not setting SA_ONSTACK for the
>>>handlers that I want to run on the thread stack.
>>>
>>>
>>
>>I have worked out a patch to support per-thread sigaltstack() state,
>>in most cases, it is just a literally replacement.
>>
>>http://people.freebsd.org/~davidxu/kse/kern_sigaltstack.diffs
> 
> 
> Looks good, but I have a question.  You removed the proc lock
> in kern_sig.c:osigstack() and kern_sig.c:kern_sigaltstack().
> What prevents a signal from being sent to the current thread
> while it is mucking with the altsigstack?  Is it possible for
> an interrupt to swap out the current thread and have a signal
> installed for it sometime later before it can complete
> sigaltstack()?  Or do signals only get installed on the way
> out of the kernel?
> 
signal stack only gets installed when thread is on the way out
of kernel. Other threads only can post signal to the thread and
may wake it up if it is sleeping, but cann't install a signal
stack for the thread, the signaled thread checks signals when
it is returning to userland, and installs signal stack for itself,
sigaltstack is private for thread, and other threads needn't to know
the signaled thread has an alternative signal stack at all.

David Xu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FF4BABA.5000601>