From owner-freebsd-emulation@FreeBSD.ORG Mon Jul 19 21:47:18 2004 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D41316A4CF for ; Mon, 19 Jul 2004 21:47:18 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.177]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2091743D5C for ; Mon, 19 Jul 2004 21:47:18 +0000 (GMT) (envelope-from gwk@rahn-koltermann.de) Received: from [212.227.126.179] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Bmfyf-0004lO-00 for freebsd-emulation@freebsd.org; Mon, 19 Jul 2004 23:47:17 +0200 Received: from [217.232.136.231] (helo=[192.168.0.3]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Bmfyf-0007ew-00 for freebsd-emulation@freebsd.org; Mon, 19 Jul 2004 23:47:17 +0200 From: "Georg-W. Koltermann" To: freebsd-emulation@freebsd.org Content-Type: text/plain Message-Id: <1090273635.1511.15.camel@localhost.muc.eu.mscsoftware.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 19 Jul 2004 23:47:15 +0200 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:90bcaad5e51ecc993b2919ba4b74e6dc Subject: how to implement linux_gettid X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2004 21:47:18 -0000 Hi, I am trying to get SUNs Linux JRE 1.5 beta2 to work, which currently fails with unsupported system call #224, which is gettid(). In the Linux kernel this call returns the pid, which makes sense as their threading model allocates a proc structure per thread. I first tried to simply return a unique number for the gettid() call by returning (int)td. That seemed to work, although I sometimes got JVM crashes with negative thread ids. Interestingly I observed that with the JRE 1.5 I also seem to get one proc per thread in our Linux emulation on FreeBSD; ps(1) shows multiple processes for one java invocation. So my current attempt is to return td->td_proc->p_pid, which is the pid just as in the Linux kernel. This also works, just as fine, for simple cases. I still get JVM crashes easily when I start a Swing GUI application and resize the window a couple times. So I suppose returning the pid is not really the correct solution. Could someone explain how our threading works when accessed from Linux, and maybe give me a hint how gettid() should be implemented correctly? -- Thanks, Regards, Georg. ------------------------------------------ FreeBSD 5.2.1-p5 linux_base-8 linprocfs is mounted Index: linux_misc.c =================================================================== RCS file: /usr/ncvs/src/sys/compat/linux/linux_misc.c,v retrieving revision 1.150 diff -u -r1.150 linux_misc.c --- linux_misc.c 16 Nov 2003 15:07:10 -0000 1.150 +++ linux_misc.c 14 Jul 2004 18:57:55 -0000 @@ -1328,6 +1328,20 @@ return (0); } +/* + * A trial implementation of linux gettid(2). + * + * We'll see if it works. The linux source returns the pid + * for this call. + */ +int +linux_gettid(struct thread *td, struct linux_gettid_args *args) +{ + /* td->td_retval[0] = (int)td; */ + td->td_retval[0] = td->td_proc->p_pid; + return (0); +} + int linux_getgid(struct thread *td, struct linux_getgid_args *args) {