什么是线程和进程id的值范围是多少? [英] what is the value range of thread and process id?

查看:3141
本文介绍了什么是线程和进程id的值范围是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在pthread_create 将返回一个进程ID或线程ID。

fork and pthread_create will return a process id or thread id.

但我不知道这些ID的取值范围。

But I don't know the value range of these ids.

现在我想打一个查找表中的每个条目有线程ID的项目/场。
每个条目的结构是这样的:

Now I want to make a lookup table, in each entry there is a item/field for thread id. the structure of each entry is like:

 typedef struct {
   int seq;
   pthread_t tid;
   ...
 } entry_t;

我要赋值为无效 TID 来条目中时,我没有得到一个线程的TID(即将本场将填充有效之一,但在此之前的填写功能将检查PID是否有效与否)。那么,什么是线程和进程id的值范围是多少?

I want to assign a value to an invalid tid to an entry when I don't get the tid of a thread(soon this field will be filled with a valid one, but before that the fill function will check whether the pid is valid or not). so, what is the value range of thread and process id?

推荐答案

的pthread_t 类型是完全不透明的。只能比较它与 pthread_equal 功能平等,没有来自任何有效的线程ID不同的无保留价值,但这种价值可能会被添加到下一个版本的POSIX标准。因此,你需要到第二场存储旁边的线程ID来跟踪它是否有效。

The pthread_t type is completely opaque. You can only compare it for equality with the pthread_equal function, and there is no reserved value distinct from any valid thread id, though such a value will probably be added to the next version of the POSIX standard. As such, you'll need to store a second field alongside the thread id to track whether it's valid or not.

这篇关于什么是线程和进程id的值范围是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆