From owner-freebsd-threads@FreeBSD.ORG Wed Nov 26 16:26:44 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 7B83116A4CE for ; Wed, 26 Nov 2003 16:26:44 -0800 (PST) Received: from dust.freshx.de (freshx.de [80.190.100.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id 83C7343FDF for ; Wed, 26 Nov 2003 16:26:41 -0800 (PST) (envelope-from kai@freshx.de) Received: from localhost (localhost.freshx.de [127.0.0.1]) by dust.freshx.de (Postfix) with ESMTP id 5AA2E15E2AE for ; Thu, 27 Nov 2003 01:26:30 +0100 (CET) Received: from localhost (localhost.freshx.de [127.0.0.1]) by dust.freshx.de (Postfix) with ESMTP id 9F6C015E200 for ; Thu, 27 Nov 2003 01:26:29 +0100 (CET) Received: from 127.0.0.1 ( [127.0.0.1]) as user dust0005@localhost by localhost with HTTP; Thu, 27 Nov 2003 01:26:29 +0100 Message-ID: <1069892789.3fc544b58a2d7@localhost> Date: Thu, 27 Nov 2003 01:26:29 +0100 From: "sapdb@komadev.de" To: freebsd-threads@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.0 X-Virus-Scanned: by AMaViS 0.3.12 Subject: Continous thread ids 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, 27 Nov 2003 00:26:44 -0000 Hi, i wrote a little thread test programm. when i run it i get an output like ... 10 of 10 threads running, i am 0x8069000 10 of 10 threads running, i am 0x806c000 10 of 10 threads running, i am 0x806f000 ... is there a generic way (not kse dependant), to get a still unique countinous thread id starting with 1,2 .... n ? With linuxthreads, it was possible by a dirty hack, masking out the upper 20 bit, but that seems not to be the way its meant to work huh ? any ideas ? kind regards kai ------------------------------------------------------------ #include #include #include #define MAXTHREADS 10 int i; void *threadedCounter(void *x) { for(int a=0;a<10;a++){ printf("%d of %d threads running, i am 0x%x\n",i,MAXTHREADS,pthread_self ()); sleep(2); } return NULL; } int main(void) { pthread *t; for(i = 0 ; i < MAXTHREADS ; i++) pthread_create(&t,NULL,threadedCounter,NULL); sleep(MAXTHREADS*3+2); return 0; }