From: Olivier Croquette <ocroquette@free.fr>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Subject: Thread and process dentifiers (CPU affinity, kill)
Date: Thu, 19 May 2005 20:00:56 +0200 [thread overview]
Message-ID: <428CD458.6010203@free.fr> (raw)
It seems that the thread ids in Linux are unique within the complete
operating system, and not only within their corresponding processes.
This is explicitely allowed by the POSIX standard (it also states that
applications shall no rely on it).
Apparently some system calls which normally require a process id also
work with thread ids.
- a system call requiring a PID can have the same effect if a thread id
of the same process was given.
Example: kill(tid,SIGTERM) will kill the entire process the thread
belongs to. I think that this is not POSIX compliant. It shall trigger
ESRCH!
Sometimes, the system call has another effect, potentialy providing
additional functionality.
Example: sched_setaffinity(). The man page and the prototype (which
requires a pid_t) both show that a process id is required. Nothing
indicates that it works with threads, and AFAIK there is no documented
way to set affinity for a specific thread.
But if you give a TID to sched_setaffinity, it will put the *thread* on
the given cpu set.
If you give a PID to sched_setaffinity, it will put the *main thread* on
the given cpu set. The other threads won't be impacted.
Even if sched_setaffinity() is no standard, I find it confusing to give
it a pid_t and that it affects only threads!
Some open questions:
- is it a guaranted behaviour within Linux that thread ids and process
ids do not overlap? is it documented anywhere?
- is there a real confusion at API level within Linux between threads
and processes or are kill() and sched_setaffinity() isolated examples?
or bugs?
- is Linux kill() POSIX compliant in this regard?
- do we want to limit the sched_setaffinity() functionality to
correspond to its documentation, or do we want to update the
documentation so that its covers all the functionality?
Regards
Olivier
next reply other threads:[~2005-05-19 18:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-19 18:00 Olivier Croquette [this message]
2005-05-19 18:23 ` Thread and process dentifiers (CPU affinity, kill) Lennart Sorensen
2005-05-19 19:46 ` Chris Friesen
2005-05-20 12:55 ` Lennart Sorensen
2005-05-20 14:51 ` Olivier Croquette
2005-05-20 16:53 ` Lennart Sorensen
2005-05-20 18:13 ` Miquel van Smoorenburg
2005-05-20 20:12 ` Lennart Sorensen
2005-05-23 12:56 ` Nix
2005-05-20 20:17 ` Olivier Croquette
2005-05-20 20:38 ` Lee Revell
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=428CD458.6010203@free.fr \
--to=ocroquette@free.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox