* [ECOS] Posix Thread name
@ 2004-05-04 3:14 Tony Butt
2004-05-13 14:00 ` Andrew Lunn
0 siblings, 1 reply; 6+ messages in thread
From: Tony Butt @ 2004-05-04 3:14 UTC (permalink / raw)
To: ecos-discuss
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
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
Fax: 02 62130013
[-- Attachment #2: pthread_name.diff --]
[-- Type: application/octet-stream, Size: 1891 bytes --]
--- ecos-2.0/packages/compat/posix/current/include/types.h 2004-05-04 11:56:10.902735600 +1000
+++ ecos-2.0.old/packages/compat/posix/current/include/types.h 2002-05-24 08:59:58.000000000 +1000
@@ -93,7 +93,6 @@
struct sched_param schedparam;
void *stackaddr;
size_t stacksize;
- char * name;
} pthread_attr_t;
// Values for detachstate
--- ecos-2.0/packages/compat/posix/current/src/pthread.cxx 2004-05-04 12:04:38.193725400 +1000
+++ ecos-2.0.old/packages/compat/posix/current/src/pthread.cxx 2004-04-02 13:35:05.000000000 +1000
@@ -594,27 +594,18 @@
// generate a name for this thread
char *name = nthread->name;
- if (use_attr.name) {
- int i;
- for (i = 0 ; use_attr.name[i] && (i < 16) ; i++)
- name[i] = use_attr.name[i];
- name[i] = '\0'; // Null terminate the name...
- }
- else {
- static char *name_template = "pthread.00000000";
- pthread_t id = nthread->id;
- int i;
-
- for( i = 0; name_template[i]; i++ ) name[i] = name_template[i];
- name[i] = '\0'; // Null terminate the name...
-
- // dump the id, in hex into the name.
- for( i = 15; i >= 8; i-- )
- {
- name[i] = "0123456789ABCDEF"[id&0xF];
- id >>= 4;
- }
+ static char *name_template = "pthread.00000000";
+ pthread_t id = nthread->id;
+
+ for( int i = 0; name_template[i]; i++ ) name[i] = name_template[i];
+
+ // dump the id, in hex into the name.
+ for( int i = 15; i >= 8; i-- )
+ {
+ name[i] = "0123456789ABCDEF"[id&0xF];
+ id >>= 4;
}
+
#endif
// Initialize the joiner condition variable
@@ -969,7 +960,6 @@
attr->stackaddr = NULL;
attr->stacksize_valid = 0;
attr->stacksize = 0;
- attr->name = NULL;
PTHREAD_RETURN(0);
}
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Posix Thread name
2004-05-04 3:14 [ECOS] Posix Thread name Tony Butt
@ 2004-05-13 14:00 ` Andrew Lunn
2004-05-13 14:08 ` Tim Sohacki
2004-05-17 9:41 ` Tony Butt
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Lunn @ 2004-05-13 14:00 UTC (permalink / raw)
To: Tony Butt; +Cc: ecos-discuss
On Tue, May 04, 2004 at 01:09:57PM +1000, Tony Butt wrote:
> 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().
As far as i can see, there is nothing in the POSIX pthread standard
like this.
Even if there was, i doubt it would be done by directly modifying the
pthread_attr structure. I would expect the POSIX people to add two new
functions, pthread_attr_setname() and pthread_attr_getname().
I think adding arbitry extensions like this to a standardized API is a
bad idea. So im tempted to not accept this contribution. Feel free to
try to change my mind.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [ECOS] Posix Thread name
2004-05-13 14:00 ` Andrew Lunn
@ 2004-05-13 14:08 ` Tim Sohacki
2004-05-13 21:02 ` Dan Jakubiec
2004-05-17 9:41 ` Tony Butt
1 sibling, 1 reply; 6+ messages in thread
From: Tim Sohacki @ 2004-05-13 14:08 UTC (permalink / raw)
To: 'Andrew Lunn', 'Tony Butt'; +Cc: ecos-discuss
fyi, Wade Jensen previously solved this with the patch at:
http://sources.redhat.com/ml/ecos-discuss/2002-06/msg00104.html
Cheers,
Tim.
-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Thursday, May 13, 2004 10:01 AM
To: Tony Butt
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Posix Thread name
On Tue, May 04, 2004 at 01:09:57PM +1000, Tony Butt wrote:
> 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().
As far as i can see, there is nothing in the POSIX pthread standard like
this.
Even if there was, i doubt it would be done by directly modifying the
pthread_attr structure. I would expect the POSIX people to add two new
functions, pthread_attr_setname() and pthread_attr_getname().
I think adding arbitry extensions like this to a standardized API is a
bad idea. So im tempted to not accept this contribution. Feel free to
try to change my mind.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [ECOS] Posix Thread name
2004-05-13 14:08 ` Tim Sohacki
@ 2004-05-13 21:02 ` Dan Jakubiec
0 siblings, 0 replies; 6+ messages in thread
From: Dan Jakubiec @ 2004-05-13 21:02 UTC (permalink / raw)
To: Tim Sohacki, 'Andrew Lunn', 'Tony Butt'; +Cc: ecos-discuss
I also ran into a similar problem a while ago. I never found any POSIX-defined way of assigned
thread names, so I just implemented my own private functions to do so.
But I agree that these sorts of non-standard POSIX enhancements probably don't belong in the
public repository. A bit of a bummer, but what I don't think there is much that can be done about
it.
--
Dan Jakubiec
Systech Corp
--- Tim Sohacki <tsohacki@telesyn.com> wrote:
> fyi, Wade Jensen previously solved this with the patch at:
> http://sources.redhat.com/ml/ecos-discuss/2002-06/msg00104.html
>
> Cheers,
> Tim.
>
>
>
> -----Original Message-----
> From: ecos-discuss-owner@ecos.sourceware.org
> [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
> Sent: Thursday, May 13, 2004 10:01 AM
> To: Tony Butt
> Cc: ecos-discuss@ecos.sourceware.org
> Subject: Re: [ECOS] Posix Thread name
>
>
> On Tue, May 04, 2004 at 01:09:57PM +1000, Tony Butt wrote:
> > 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().
>
> As far as i can see, there is nothing in the POSIX pthread standard like
> this.
>
> Even if there was, i doubt it would be done by directly modifying the
> pthread_attr structure. I would expect the POSIX people to add two new
> functions, pthread_attr_setname() and pthread_attr_getname().
>
> I think adding arbitry extensions like this to a standardized API is a
> bad idea. So im tempted to not accept this contribution. Feel free to
> try to change my mind.
>
> Andrew
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>
>
> --
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Posix Thread name
2004-05-13 14:00 ` Andrew Lunn
2004-05-13 14:08 ` Tim Sohacki
@ 2004-05-17 9:41 ` Tony Butt
2004-05-17 11:06 ` Tony Butt
1 sibling, 1 reply; 6+ messages in thread
From: Tony Butt @ 2004-05-17 9:41 UTC (permalink / raw)
To: Andrew Lunn; +Cc: ecos-discuss
On Thu, 13 May 2004 16:01:14 +0200
Andrew Lunn <andrew@lunn.ch> wrote:
> On Tue, May 04, 2004 at 01:09:57PM +1000, Tony Butt wrote:
> > 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().
>
> As far as i can see, there is nothing in the POSIX pthread standard
> like this.
Yes - I don't think there is even a concept of a thread name, so certainly no mechanism to set one.
>
> Even if there was, i doubt it would be done by directly modifying the
> pthread_attr structure. I would expect the POSIX people to add two new
> functions, pthread_attr_setname() and pthread_attr_getname().
Yes, that would be more in line with the general posix threads approach.
>
> I think adding arbitry extensions like this to a standardized API is a
> bad idea. So im tempted to not accept this contribution. Feel free to
> try to change my mind.
My intent was to provide a mechanism to set the name before the thread was created,
in the same way that some other attributes are set. I don't know if the contents of
pthread_attr_t are completely specified, or just the interface functions (my Posix references are
a bit thin on the ground here). That would be my only grounds for requesting an inclusion (thin as they are)
Thanks for looking at it anyway...
>
> Andrew
--
----------------------------------
Tony Butt
CEA Technologies
----------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [ECOS] Posix Thread name
2004-05-17 9:41 ` Tony Butt
@ 2004-05-17 11:06 ` Tony Butt
0 siblings, 0 replies; 6+ messages in thread
From: Tony Butt @ 2004-05-17 11:06 UTC (permalink / raw)
To: ecos-discuss
While we are at it, I don't suppose there is a pre-existing way to suspend
and resume a posix thread, short of my writing my own
pthread_resume()/pthread_suspend pair, and further bending the posix spec?
Tony Butt
CEA Technologies
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-05-17 4:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-04 3:14 [ECOS] Posix Thread name Tony Butt
2004-05-13 14:00 ` Andrew Lunn
2004-05-13 14:08 ` Tim Sohacki
2004-05-13 21:02 ` Dan Jakubiec
2004-05-17 9:41 ` Tony Butt
2004-05-17 11:06 ` Tony Butt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).