linux中pid gid tgid tid的区别和联系

getpid : 取得process id,对于thread,就是取得线程对应进程的id;

对应的system call:

 asmlinkage long sys_getpid(void)
1614 {
1615         return current->tgid;
1616 }

tgid = thread group id

 

/

 

gettid:取得线程id,如果是process,其实就等于getpid:

#define gettid() syscall(__NR_gettid)

对应的system call:

/* Thread ID - the internal kernel "pid" */
1761 asmlinkage long sys_gettid(void)
1762 {
1763         return current->pid;
1764 }

 

 

getgid:取得group id,就是user的group id

和用id命令得到的group id是一回事:

bash-3.1$ id
uid=3013(xxx) gid=300(xxxx) groups=300(xxxx),301(platform),505(fpgadrv),9022(gsm)

 

对于一个thread来说,在kenerl中可以看到他的process id(tgid),还可以看到他的thread id(pid)

 

 

你可能感兴趣的:(linux中pid gid tgid tid的区别和联系)