Date: Mon, 8 Feb 2010 13:38:06 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: Shrivats <shrivatsan_v@yahoo.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Invoking a signal handler Message-ID: <20100208113806.GI9991@deviant.kiev.zoral.com.ua> In-Reply-To: <780520.92654.qm@web112015.mail.gq1.yahoo.com> References: <780520.92654.qm@web112015.mail.gq1.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--zqjkMoGlbUJ91oFe Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 07, 2010 at 10:55:53PM -0800, Shrivats wrote: > Hi, >=20 >=20 > I am trying to understand how the kernel invokes the signal handler for a process, to deliver an asynchronous signal posted by another process. > I was looking at the sendsig() function which saves the current user > context. My question is, when and how does the transition from the > kernel mode to the user mode take place so that the signal handler is > invoked?=9A The sendsig() does two things. First, it copies out the currently saved user context to the user stack. Then, it modifies the current context to arrange the call to the signal handler when return to user mode is done. After that, when the thread does usual return from the kernel to user mode, be it return from the interrupt, or syscall, the modified context causes execution to jump to signal trampoline code implanted to the user mode stack by image activator. Trampoline is supplied required data by sendsig() to call signal handler with the right arguments. More, upon return from the signal handler, the trampoline on the stack gets the control again, and calls sigreturn(2) syscall that restores the old, pre-signal context saved by sendsig(). This is the model used on i386/amd64 FreeBSD, and I think that other architectures are quite similar. --zqjkMoGlbUJ91oFe Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAktv954ACgkQC3+MBN1Mb4hPigCgotuDK/8qFah4QQev0MMIfLHr E8YAn1zUwVqk1cFJAJExMa/QqlttBvsB =6chm -----END PGP SIGNATURE----- --zqjkMoGlbUJ91oFe--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100208113806.GI9991>
