鱼C论坛

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

[吹水] PID和TID

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

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

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

x
帖子的PID和TID是什么呢? 怎样查看?
想知道小甲鱼最近在做啥?请访问 -> 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  木有发现
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-1-12 16:09:38 | 显示全部楼层
pid - process identifier
tid - thread identifier
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

???怎么查看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

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

void *task(void *arg) {
    printf("task - arg: %d\n", *(int *)arg);
    printf("task - pid: %x\n", getpid());
    printf("task - tid: %lx\n", pthread_self());
    return arg;
}

int main(void) {
    printf("main - pid: %x\n", getpid());
    printf("main - tid: %lx\n", pthread_self());
    pthread_t t0, t1;
    int a = 123, b = 456;
    pthread_create(&t0, NULL, task, &a);
    pthread_create(&t1, NULL, task, &b);
    pthread_join(t0, NULL);
    pthread_join(t1, NULL);
    return 0;
}
sh-5.1$ gcc -g -Wall -o main main.c
sh-5.1$ ./main
main - pid: aa736
main - tid: 7f55fc8b9680
task - arg: 456
task - pid: aa736
task - tid: 7f55fbecd6c0
task - arg: 123
task - pid: aa736
task - tid: 7f55fc6ce6c0
sh-5.1$
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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


......
我说的是在浏览器里......
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 0 反对 1

使用道具 举报

发表于 2023-1-12 18:37:12 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-23 23:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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