From owner-freebsd-threads@FreeBSD.ORG Mon Jun 16 18:55:46 2003 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 AF8AC37B401 for ; Mon, 16 Jun 2003 18:55:46 -0700 (PDT) Received: from wall.polstra.com (wall-gw.polstra.com [206.213.73.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id CB52443FCB for ; Mon, 16 Jun 2003 18:55:45 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from strings.polstra.com (strings.polstra.com [206.213.73.20]) by wall.polstra.com (8.12.3p2/8.12.3) with ESMTP id h5H1tjPL045108 for ; Mon, 16 Jun 2003 18:55:45 -0700 (PDT) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Mon, 16 Jun 2003 18:55:44 -0700 (PDT) From: John Polstra To: freebsd-threads@freebsd.org X-Bogosity: No, tests=bogofilter, spamicity=0.497234, version=0.11.2 Subject: getcontext() for a different thread 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: Tue, 17 Jun 2003 01:55:47 -0000 I've been toying with the idea of making Modula-3 use FreeBSD's native threads library. One thing that would be required is something like getcontext() that could be called to get the context of a different thread. That is needed by the garbage collector, because it has to examine all of the threads' registers in case some of them contain pointers to objects that need to be traced. Are there any major obstacles to implementing this? I see that getcontext() in the kernel already takes a "struct thread *" argument. But it calls get_mcontext(), which (at least on the i386) references "curthread" a couple of times. Is that really necessary, or could "td" be used in place of "curthread"? An other-thread getcontext would have to be passed a kernel thread handle of some sort. Is there currently anything like that which is exposed to userland? An other-thread getcontext would have to do some security checks to make sure you weren't trying to read the register of a thread that didn't belong to you. Anything else? John -- John Polstra John D. Polstra & Co., Inc. Seattle, Washington USA "Two buttocks cannot avoid friction." -- Malawi saying