鱼C论坛

 找回密码
 立即注册
查看: 4131|回复: 6

[吹水] PID和TID

[复制链接]
发表于 2023-1-12 14:29:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
帖子的PID和TID是什么呢? 怎样查看?
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2023-1-12 15:03:45 | 显示全部楼层
https://fishc.com.cn/forum.php?mod=viewthread&tid=223338&extra=page%3D1&ordertype=1

tid    有发现

pid  木有发现
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-1-12 16:09:38 | 显示全部楼层
pid - process identifier
tid - thread identifier
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-1-12 18:09:21 | 显示全部楼层
人造人 发表于 2023-1-12 16:09
pid - process identifier
tid - thread identifier

???怎么查看
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-1-12 18:34:17 | 显示全部楼层

  1. sh-5.1$ cat main.c
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <pthread.h>

  5. void *task(void *arg) {
  6.     printf("task - arg: %d\n", *(int *)arg);
  7.     printf("task - pid: %x\n", getpid());
  8.     printf("task - tid: %lx\n", pthread_self());
  9.     return arg;
  10. }

  11. int main(void) {
  12.     printf("main - pid: %x\n", getpid());
  13.     printf("main - tid: %lx\n", pthread_self());
  14.     pthread_t t0, t1;
  15.     int a = 123, b = 456;
  16.     pthread_create(&t0, NULL, task, &a);
  17.     pthread_create(&t1, NULL, task, &b);
  18.     pthread_join(t0, NULL);
  19.     pthread_join(t1, NULL);
  20.     return 0;
  21. }
  22. sh-5.1$ gcc -g -Wall -o main main.c
  23. sh-5.1$ ./main
  24. main - pid: aa736
  25. main - tid: 7f55fc8b9680
  26. task - arg: 456
  27. task - pid: aa736
  28. task - tid: 7f55fbecd6c0
  29. task - arg: 123
  30. task - pid: aa736
  31. task - tid: 7f55fc6ce6c0
  32. sh-5.1$
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-1-12 18:36:11 | 显示全部楼层


......
我说的是在浏览器里......
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 0 反对 1

使用道具 举报

发表于 2023-1-12 18:37:12 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-1 13:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表