linux 怎么查看进程的tid

linux 怎么查看进程的tid,第1张

查看进程的所有线程

# ps mp 6648 -o THREAD,tid

USER %CPU PRI SCNT WCHAN USER SYSTEM TID

root 0.0 -- - - - -

root 0.0 24- - - - 6648

root 0.0 21- - - - 6650

root 1.0 24- - - - 14214

root 0.0 23- futex_- - 14216

root 0.0 22- 184466- - 15374

root 0.0 23- 184466- - 15376

root 0.0 23- 184466- - 15378

root 0.0 23- 184466- - 15380

root 0.0 23- 184466- - 15392

root 0.0 23- 184466- - 15394

root 0.0 23- 184466- - 15398

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中有这么一种思想,内存不用白不用,因此它尽可能的cache和buffer一些数据..."main" prio=5 tid=1 NATIVE | group="main" sCount=1 dsCount=0 obj=...


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7246153.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存