how kernel distinguish threads

Chuck Ebbert cebbert at redhat.com
Mon Jul 9 22:44:02 UTC 2007


On 07/09/2007 06:29 PM, Feng Xian wrote:
> Hi, I am working on a project about reducing page faults of multi-threaded
> programs. I am using latest Fedora core (Linux 2.6) and pthread library. In
> this project, each user-level  thread (created by pthread_create()
> function)
> needs to pass a value to the task structure in the kernel which corresponds
> to the thread. The first step is getting a unique id of the task structure
> of each thread. But what is this unique id?
> 
> I tried to use getpid() to get the process id of each thread and use it as
> unique id. But this didnt work out since all threads in a process share the
> same pid. I tried to use the thread_id returned by pthread_create()
> function
> but this id is meaningless to the kernel. Could anyone help me out on this?

Use gettid() ??




More information about the Fedora-kernel-list mailing list