henrylee1991 发表于 2012-12-17 14:40

apue 11.3节有关线程标识问题

本帖最后由 henrylee1991 于 2012-12-17 14:42 编辑

apue第288页有一段话写道:

线程id则用pthread_t数据类型来表示,实现的时候可以用一个结构来代表pthread_t数据类型,所以可移植的操作系统实现不能把它作为整数处理。

“可移植的操作系统实现不能把它作为整数处理”这句话怎么理解?

还有为什么pthread_t是结构类型,我查了一下它是 typedef unsigned long int pthread_t;

crazyhadoop 发表于 2012-12-18 08:55

pthread_t 不能当做整数处理,是说在不同的系统下,pthread_t 的实现是不同的, 比如在linux下 是 unsigned long int,但是在windows系统下,是这样的~
typedef struct {
    void * p;               
    unsigned int x;         
} ptw32_handle_t;
typedef ptw32_handle_t pthread_t;

henrylee1991 发表于 2012-12-18 11:08

那pid_t在linux和windows下的定义都是一样的吗?

crazyhadoop 发表于 2012-12-18 17:12

回复 3# henrylee1991


    windows下没有pid_t 这个结构吧

henrylee1991 发表于 2012-12-19 09:15

哦,原来如此。
页: [1]
查看完整版本: apue 11.3节有关线程标识问题