Thread ID unique?

NTFSD Folk:

I think this is an easy question, but I couldn’t find a definitive answer.

Is a thread ID guaranteed to be unique at any given time? That is, could
the same thread ID be used in different processes at any instant?

I realize that thread IDs get re-used, but not sure if I need to track both
process ID and thread ID together, or if just thread ID is sufficient.

Thanks,
Ken

> Is a thread ID guaranteed to be unique at any given time? That is, could

the same thread ID be used in different processes at any instant?
Yes, I read it somewhere (Mark’s bible?) that thread IDs are unique
(no two threads can have same IDs, and it is true whether they are in
the same process or different ones).

----- Original Message -----
From: “Ken Cross”
To: “Windows File Systems Devs Interest List”
Sent: Saturday, March 25, 2006 10:33 AM
Subject: [ntfsd] Thread ID unique?

> NTFSD Folk:
>
> I think this is an easy question, but I couldn’t find a definitive answer.
>
> Is a thread ID guaranteed to be unique at any given time? That is, could
> the same thread ID be used in different processes at any instant?
>
> I realize that thread IDs get re-used, but not sure if I need to track
> both
> process ID and thread ID together, or if just thread ID is sufficient.
>
> Thanks,
> Ken
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@comcast.net
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Thread IDs are handles out of a special handle table and as such are
always unique. This is also how the OS can quickly convert from a thread
(or process) id to the corresponding thread (or process) object quickly

  • just use the object manager’s handle table management mechanism.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Saturday, March 25, 2006 10:33 AM
To: ntfsd redirect
Subject: [ntfsd] Thread ID unique?

NTFSD Folk:

I think this is an easy question, but I couldn’t find a definitive
answer.

Is a thread ID guaranteed to be unique at any given time? That is,
could
the same thread ID be used in different processes at any instant?

I realize that thread IDs get re-used, but not sure if I need to track
both
process ID and thread ID together, or if just thread ID is sufficient.

Thanks,
Ken


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

>I realize that thread IDs get re-used

Yes, ofcourse the thread-ids are unique within a system but as per my
understanding you are having concern that same thread-id is being used
twice.
It is quite possible that a process finishes working with a thread and then
that thread is re-used by some other process so as to do its work without
destroying that thread.
If I am wrong, someone please correct me.

Regards,
Shreshth

On 3/25/06, Tony Mason wrote:
>
> Thread IDs are handles out of a special handle table and as such are
> always unique. This is also how the OS can quickly convert from a thread
> (or process) id to the corresponding thread (or process) object quickly
> - just use the object manager’s handle table management mechanism.
>
> Regards,
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> Looking forward to seeing you at the next OSR File Systems class in
> Boston, MA April 18-21, 2006.
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
> Sent: Saturday, March 25, 2006 10:33 AM
> To: ntfsd redirect
> Subject: [ntfsd] Thread ID unique?
>
> NTFSD Folk:
>
> I think this is an easy question, but I couldn’t find a definitive
> answer.
>
> Is a thread ID guaranteed to be unique at any given time? That is,
> could
> the same thread ID be used in different processes at any instant?
>
> I realize that thread IDs get re-used, but not sure if I need to track
> both
> process ID and thread ID together, or if just thread ID is sufficient.
>
> Thanks,
> Ken
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@osr.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

No, I’m not concerned that the same thread ID gets re-used – that’s
understood. But you can be assured that any open files will be closed
before it gets re-used.

My question was whether the thread ID was sufficient to track who is
accessing a file, or if the process id was necessary, too.

FWIW, there are some flavors of *nix that duplicate thread IDs. Process A
can have threads 1, 2, and 3, and Process B can also have threads 1, 2, and
3. So you need both the process and thread to identify a unique thread.

I wanted to make sure that wasn’t the case in Windows. I’m convinced it’s
not.

Ken


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shreshth Luthra
Sent: Sunday, March 26, 2006 9:40 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Thread ID unique?

I realize that thread IDs get re-used

Yes, ofcourse the thread-ids are unique within a system but as per my
understanding you are having concern that same thread-id is being used
twice.
It is quite possible that a process finishes working with a thread and then
that thread is re-used by some other process so as to do its work without
destroying that thread.
If I am wrong, someone please correct me.

Regards,
Shreshth

On 3/25/06, Tony Mason wrote:

Thread IDs are handles out of a special handle table and as such are
always unique. This is also how the OS can quickly convert from a
thread
(or process) id to the corresponding thread (or process) object
quickly
- just use the object manager’s handle table management mechanism.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Saturday, March 25, 2006 10:33 AM
To: ntfsd redirect
Subject: [ntfsd] Thread ID unique?

NTFSD Folk:

I think this is an easy question, but I couldn’t find a definitive
answer.

Is a thread ID guaranteed to be unique at any given time? That is,
could
the same thread ID be used in different processes at any instant?

I realize that thread IDs get re-used, but not sure if I need to
track
both
process ID and thread ID together, or if just thread ID is
sufficient.

Thanks,
Ken


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
https:

You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com

— Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17 You are currently subscribed to
ntfsd as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com</https:>

Ken,

Actually, your description makes it sound like you DO need the process
ID. Thread IDs can certainly be reused over the lifetime of a single
file handle. Thread IDs (and Process IDs) are a disjoint “special”
handle table. The insertion and removal of elements from that table is
independent of the file handles (which live in the per-process object
handle table.) A thread object may ALSO have a process-level handle
(dup handle will do this for instance) but the “thread ID” and its
reusage is not tied in any way to recycling the process.

In other words, thread id 1024 might come into existence, that thread
might open a half dozen files in process 512 and then exit. Then when
process 668 creates a thread IT might have thread id 1024, even though
those original files (and their handles) still exist in the object
handle table of process 512.

Not sure if this helps, or not.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Sunday, March 26, 2006 10:54 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Thread ID unique?

No, I’m not concerned that the same thread ID gets re-used – that’s
understood. But you can be assured that any open files will be closed
before it gets re-used.

My question was whether the thread ID was sufficient to track who is
accessing a file, or if the process id was necessary, too.

FWIW, there are some flavors of *nix that duplicate thread IDs. Process
A
can have threads 1, 2, and 3, and Process B can also have threads 1, 2,
and
3. So you need both the process and thread to identify a unique thread.

I wanted to make sure that wasn’t the case in Windows. I’m convinced
it’s
not.

Ken


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shreshth Luthra
Sent: Sunday, March 26, 2006 9:40 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Thread ID unique?

I realize that thread IDs get re-used

Yes, ofcourse the thread-ids are unique within a system but as per my
understanding you are having concern that same thread-id is being used
twice.
It is quite possible that a process finishes working with a thread and
then
that thread is re-used by some other process so as to do its work
without
destroying that thread.
If I am wrong, someone please correct me.

Regards,
Shreshth

On 3/25/06, Tony Mason wrote:

Thread IDs are handles out of a special handle table and as such
are
always unique. This is also how the OS can quickly convert from
a
thread
(or process) id to the corresponding thread (or process) object
quickly
- just use the object manager’s handle table management
mechanism.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class
in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Saturday, March 25, 2006 10:33 AM
To: ntfsd redirect
Subject: [ntfsd] Thread ID unique?

NTFSD Folk:

I think this is an easy question, but I couldn’t find a
definitive
answer.

Is a thread ID guaranteed to be unique at any given time? That
is,
could
the same thread ID be used in different processes at any
instant?

I realize that thread IDs get re-used, but not sure if I need to
track
both
process ID and thread ID together, or if just thread ID is
sufficient.

Thanks,
Ken


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
https:

You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com

— Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17 You are currently subscribed
to
ntfsd as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank
email
to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</https:>

Well, at the very least it raises some doubt. So heck – it’s not that big
a deal to check both process and thread…

Thanks,
Ken

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Sunday, March 26, 2006 1:13 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Thread ID unique?

Ken,

Actually, your description makes it sound like you DO need the process
ID. Thread IDs can certainly be reused over the lifetime of a single
file handle. Thread IDs (and Process IDs) are a disjoint “special”
handle table. The insertion and removal of elements from that table is
independent of the file handles (which live in the per-process object
handle table.) A thread object may ALSO have a process-level handle
(dup handle will do this for instance) but the “thread ID” and its
reusage is not tied in any way to recycling the process.

In other words, thread id 1024 might come into existence, that thread
might open a half dozen files in process 512 and then exit. Then when
process 668 creates a thread IT might have thread id 1024, even though
those original files (and their handles) still exist in the object
handle table of process 512.

Not sure if this helps, or not.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Sunday, March 26, 2006 10:54 AM
To: ntfsd redirect
Subject: RE: [ntfsd] Thread ID unique?

No, I’m not concerned that the same thread ID gets re-used – that’s
understood. But you can be assured that any open files will be closed
before it gets re-used.

My question was whether the thread ID was sufficient to track who is
accessing a file, or if the process id was necessary, too.

FWIW, there are some flavors of *nix that duplicate thread IDs. Process
A
can have threads 1, 2, and 3, and Process B can also have threads 1, 2,
and
3. So you need both the process and thread to identify a unique thread.

I wanted to make sure that wasn’t the case in Windows. I’m convinced
it’s
not.

Ken


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shreshth Luthra
Sent: Sunday, March 26, 2006 9:40 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Thread ID unique?

I realize that thread IDs get re-used

Yes, ofcourse the thread-ids are unique within a system but as per my
understanding you are having concern that same thread-id is being used
twice.
It is quite possible that a process finishes working with a thread and
then
that thread is re-used by some other process so as to do its work
without
destroying that thread.
If I am wrong, someone please correct me.

Regards,
Shreshth

On 3/25/06, Tony Mason wrote:

Thread IDs are handles out of a special handle table and as such
are
always unique. This is also how the OS can quickly convert from
a
thread
(or process) id to the corresponding thread (or process) object
quickly
- just use the object manager’s handle table management
mechanism.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the next OSR File Systems class
in
Boston, MA April 18-21, 2006.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Cross
Sent: Saturday, March 25, 2006 10:33 AM
To: ntfsd redirect
Subject: [ntfsd] Thread ID unique?

NTFSD Folk:

I think this is an easy question, but I couldn’t find a
definitive
answer.

Is a thread ID guaranteed to be unique at any given time? That
is,
could
the same thread ID be used in different processes at any
instant?

I realize that thread IDs get re-used, but not sure if I need to
track
both
process ID and thread ID together, or if just thread ID is
sufficient.

Thanks,
Ken


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
https:

You are currently subscribed to ntfsd as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com

— Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17 You are currently subscribed
to
ntfsd as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank
email
to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com</https:>

> I realize that thread IDs get re-used, but not sure if I need to track both

process ID and thread ID together, or if just thread ID is sufficient.

Thread ID is enough.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> Yes, I read it somewhere (Mark’s bible?) that thread IDs are unique

Thread and process IDs are generated by the same mechanism as handles, using
some special “PID handle table”.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com