Re: Thread and process dentifiers (CPU affinity, kill)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lennart Sorensen wrote:
On Thu, May 19, 2005 at 08:00:56PM +0200, Olivier Croquette wrote:

- 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!


How should kill know if you are sending a threadid or processid?

Doesn't matter. From a userspace point of view there is no process with that PID, so kill() should return ESRCH. In the kernel, I think this means that kill() should actually be looking up tgids rather than pids.

- is Linux kill() POSIX compliant in this regard?

Does posix say that a process can't be allocated multiple PIDs?

PID="process ID"

You have one PID per process.

- 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?

I believe Linux currently implements threads as seperate processes

No, they are implemented as separately schedulable entities with lots of shared state. "process" and "thread" are POSIX terms that don't really mean anything in the kernel.

Now given linux runs threads as seperate processes, it makes sense that
thread ids and process ids are the same thing and hence currently
unique, and that kill would work on any thread's pid within a given
process.

Pthreads define signal handling. Signals are delivered to the process as a whole, not to any particular thread. If you specify a TID that is not a valid PID, then the kernel should return an error.

Doesn't sched_setaffinity do what it says it will?  Since each thread is
treated as a process then sched_setaffinity should work on it I would
think since it is a process after all as far as the scheduler is
concerned.

If the syscall is supposed to operate on processes, it should operate on all threads within a process. It would be nice to have a way to specify affinity for threads. POSIX doesn't define one though.

Chris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux