From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15985 invoked by alias); 4 May 2004 03:14:04 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 15976 invoked from network); 4 May 2004 03:14:03 -0000 Received: from unknown (HELO lab.cea.com.au) (203.24.61.10) by sources.redhat.com with SMTP; 4 May 2004 03:14:03 -0000 Received: from localhost (localhost [127.0.0.1]) by lab.cea.com.au (Postfix) with ESMTP id ED46F10A8 for ; Tue, 4 May 2004 13:14:01 +1000 (EST) Received: from lab.cea.com.au ([127.0.0.1]) by localhost (lab.cea.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00431-01 for ; Tue, 4 May 2004 13:13:58 +1000 (EST) Received: by lab.cea.com.au (Postfix, from userid 10) id 1B9CC976; Tue, 4 May 2004 13:13:58 +1000 (EST) Received: from swmanx (sw-manx.cea.com.au [172.16.2.39]) by leopard.cea.com.au (Postfix) with ESMTP id E94664F3AA for ; Tue, 4 May 2004 13:09:57 +1000 (EST) From: "Tony Butt" To: Date: Tue, 04 May 2004 03:14:00 -0000 Organization: CEA Technologies Message-ID: <002b01c43185$47eb7080$270210ac@cea.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_002C_01C431D9.19978080" X-Virus-Scanned: by amavisd-new at cea.com.au Subject: [ECOS] Posix Thread name X-SW-Source: 2004-05/txt/msg00022.txt.bz2 ------=_NextPart_000_002C_01C431D9.19978080 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-length: 538 I had a requirement to be able to explicitly set the name of a posix thread, made some simple changes to posix/current/src/pthread.cxx and posix/current/include/types.h, and can now optionally set the name of a posix thread created using pthread_create. The name is set by assigning a value to pthread_attr.name before calling pthread_create(). A patch to do this is attached. If this should be sent anywhere else, please let me know... Tony Butt Software Engineer CEA Technologies tjb@cea.com.au Ph: 02 62130195=20 Fax: 02 62130013 ------=_NextPart_000_002C_01C431D9.19978080 Content-Type: application/octet-stream; name="pthread_name.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pthread_name.diff" Content-length: 2171 --- ecos-2.0/packages/compat/posix/current/include/types.h 2004-05-04 11:56= :10.902735600 +1000=0A= +++ ecos-2.0.old/packages/compat/posix/current/include/types.h 2002-05-24 0= 8:59:58.000000000 +1000=0A= @@ -93,7 +93,6 @@=0A= struct sched_param schedparam;=0A= void *stackaddr;=0A= size_t stacksize;=0A= - char * name;=0A= } pthread_attr_t;=0A= =20=0A= // Values for detachstate=0A= --- ecos-2.0/packages/compat/posix/current/src/pthread.cxx 2004-05-04 12:04= :38.193725400 +1000=0A= +++ ecos-2.0.old/packages/compat/posix/current/src/pthread.cxx 2004-04-02 1= 3:35:05.000000000 +1000=0A= @@ -594,27 +594,18 @@=0A= // generate a name for this thread=0A= =20=0A= char *name =3D nthread->name;=0A= - if (use_attr.name) {=0A= - int i;=0A= - for (i =3D 0 ; use_attr.name[i] && (i < 16) ; i++)=0A= - name[i] =3D use_attr.name[i];=0A= - name[i] =3D '\0'; // Null terminate the name...=0A= - }=0A= - else {=0A= - static char *name_template =3D "pthread.00000000";=0A= - pthread_t id =3D nthread->id;=0A= - int i;=0A= -=20=20=20=20=0A= - for( i =3D 0; name_template[i]; i++ ) name[i] =3D name_template[i];=0A= - name[i] =3D '\0'; // Null terminate the name...=0A= -=0A= - // dump the id, in hex into the name.=0A= - for( i =3D 15; i >=3D 8; i-- )=0A= - {=0A= - name[i] =3D "0123456789ABCDEF"[id&0xF];=0A= - id >>=3D 4;=0A= - }=0A= + static char *name_template =3D "pthread.00000000";=0A= + pthread_t id =3D nthread->id;=0A= +=20=20=20=20=0A= + for( int i =3D 0; name_template[i]; i++ ) name[i] =3D name_template[i]= ;=0A= +=0A= + // dump the id, in hex into the name.=0A= + for( int i =3D 15; i >=3D 8; i-- )=0A= + {=0A= + name[i] =3D "0123456789ABCDEF"[id&0xF];=0A= + id >>=3D 4;=0A= }=0A= +=0A= #endif=0A= =20=0A= // Initialize the joiner condition variable=0A= @@ -969,7 +960,6 @@=0A= attr->stackaddr =3D NULL;=0A= attr->stacksize_valid =3D 0;=20=20=20=20=0A= attr->stacksize =3D 0;=0A= - attr->name =3D NULL;=0A= =20=20=20=20=20=0A= PTHREAD_RETURN(0);=0A= }=0A= =0A= ------=_NextPart_000_002C_01C431D9.19978080 Content-Type: text/plain; charset=us-ascii Content-length: 148 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ------=_NextPart_000_002C_01C431D9.19978080--