All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Daniel Schnell <daniel.schnell@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] pthread_setname_np
Date: Wed, 15 Nov 2006 15:52:46 +0100	[thread overview]
Message-ID: <455B29BE.3060805@domain.hid> (raw)
In-Reply-To: <DD39B5C3F4963040ADC9768BE7E430CB0154EFA2@domain.hid>

Daniel Schnell wrote:
> Gilles Chanteperdrix wrote:
> 
> 
>>>The switchtest program works here correctly as well. Looking at the
>>>switchtest code I found out that one has to call this function
>>>_after_ one has actually created the thread with pthread_create()
>>>not like pthread_attr_setXXXX() functions which have to be called
>>>before. After changing the order in my code, it worked there as well.
>>>
>>>Is this behaviour intended ?
>>
>>pthread_set_name_np requires a pthread_t argument, and returns ESRCH
>>if this argument is invalid. It is supposed to be documented at:
>>
> 
> http://www.xenomai.org/documentation/trunk/html/api/group__posix__thread
> .html#g414a759c928f7be7ac105980d8e73431
> 
> Yes it is documented and one can guess that the function only should be
> called for a valid thread, i.e. a thread that is already created by
> reading the part of the documentation which mentions the error code.

You are being dishonest: the function expects a pthread_t argument, the
only way to get a valid pthread_t value is to create a thread or to call
pthread_self().


> 
> But as this is a non standard function and normally for Posix threads
> one expects to specify all attributes before spawning a thread (compare
> also pthread_attr_setname_np()), maybe one should add a sentence in the
> documentation, stating that this function is only valid for an already
> running thread.

Look again at the POSIX API: functions which set an attribute before
spawning the thread are all called pthread_attr_*, pthread_set_name_np
is not the only function which allow to change the attribute of a
running thread, there is also pthread_detach or pthread_setschedparam.
Like these standard functions pthread_set_name_np is prefixed with
pthread, and not with pthread_attr.


> 
> Btw. Is there a reason why the call to pthread_attr_setname_np() is
> limited to kernel space ?

It is impossible to implement pthread_attr_setname_np in user-space. I
think I will remove this call, having different APIs in kernel-space and
user-space only adds confusion.

-- 
                                                 Gilles Chanteperdrix


  reply	other threads:[~2006-11-15 14:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-15 11:27 [Xenomai-help] pthread_setname_np Daniel Schnell
2006-11-15 13:10 ` Gilles Chanteperdrix
2006-11-15 13:31   ` Daniel Schnell
2006-11-15 13:43     ` Gilles Chanteperdrix
2006-11-15 14:26       ` Daniel Schnell
2006-11-15 14:52         ` Gilles Chanteperdrix [this message]
2006-11-15 15:49           ` Daniel Schnell
2006-11-15 16:08             ` Gilles Chanteperdrix
2006-11-15 16:56               ` [Xenomai-help] [PATCH] pthread_setname_np Daniel Schnell
2006-11-15 17:50                 ` Philippe Gerum
2006-11-15 17:02               ` [Xenomai-help] pthread_setname_np Daniel Schnell
2006-11-15 17:55                 ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=455B29BE.3060805@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=daniel.schnell@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.