From owner-freebsd-threads@FreeBSD.ORG Thu Feb 5 09:24:10 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DA8B816A4CE for ; Thu, 5 Feb 2004 09:24:10 -0800 (PST) Received: from raven.ravenbrook.com (raven.ravenbrook.com [193.82.131.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC6A543D31 for ; Thu, 5 Feb 2004 09:24:08 -0800 (PST) (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (thrush.ravenbrook.com [193.112.141.145]) i15HO2Wm004631; Thu, 5 Feb 2004 17:24:03 GMT (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (localhost [127.0.0.1]) by thrush.ravenbrook.com (8.12.9/8.12.9) with ESMTP id i15HO2lb063036; Thu, 5 Feb 2004 17:24:02 GMT (envelope-from nb@thrush.ravenbrook.com) From: Nick Barnes To: Daniel Eischen In-Reply-To: from Daniel Eischen of "Thu, 05 Feb 2004 09:27:37 -0500" Date: Thu, 05 Feb 2004 17:24:02 +0000 Message-ID: <63035.1076001842@thrush.ravenbrook.com> Sender: nb@ravenbrook.com cc: Julian Elischer cc: freebsd-threads@FreeBSD.org Subject: Re: bin/31661: pthread_kill signal handler doesn't get sigcontext or ucontext X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Feb 2004 17:24:11 -0000 At 2004-02-05 14:27:37+0000, Daniel Eischen writes: > On Thu, 5 Feb 2004, Nick Barnes wrote: > > > At 2004-02-05 01:03:43+0000, Daniel Eischen writes: > > > > > See pthread_resume_all_np(3), pthread_resume_np(3), pthread_suspend_all(3), > > > and pthread_suspend_allnp(3) :-) This is what the native JDK uses for > > > GC. > > > > Way cool. Can I get the context (i.e. registers) of a suspended thread? > > No, you can get the thread attributes which include the stack base > and addr, see pthread_attr_get_np(3). The JDK seems to make do > without getting suspended thread context. Somehow the GC must see the registers of each suspended thread, so that it can preserve any objects to which the registers point. Presumably the thread context is stored in some region which the GC treats as a root (e.g. on the thread stack, identified with pthread_attr_get_np, as you say). A GC which has more information (e.g. the IP, the SP) may be able to use more sophisticated techniques (by using compiler-generated object liveness information, or by excluding dead areas of a stack segment from consideration as roots). The limit of this is a system with close-coupled compiler, thread system, and GC, which can do "precise collection", including modifying the values of registers and stack slots. Nick B