Linux pid tid gid

Source: Internet
Author: User

Pid:

GETPID Get Process ID

Tid

Gettid: Gets the thread ID, if it is a process, equals getpid

Gid:

Getgid:user Group ID

Reference StackOverflow

It is complicated: pid is process identifier; tid is thread identifier.

But as it happens, the kernel doesn ' t make a real distinction between them:threads is just like processes but they share Some things (memory, FDS ...) with other instances of the same group.

So, a tid was actually the identifier of the Schedulable object in the kernel (thread), while the PID is The identifier of the group of Schedulable objects that share memory and FDS (process).

Things more interesting, when a process had only one thread (the initial situation and in the good old times T He only one) the PID and the tid is always the same. So any function, the works with atid would automatically work with a pid.

It is worth noting this many Functions/system Calls/command line utilities documented to work with pidactually us E tids. But if the effect are process-wide you'll simply not notice the difference.

Original: Http://stackoverflow.com/questions/4517301/difference-between-pid-and-tid

Other than that:

Gettid is the ID of the thread in the kernel, pthread_self is the POSIX thread ID

Linux pid tid gid

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.