Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Funny way how to get thread specific id
Funny way how to get thread specific id [message #7642] Fri, 12 January 2007 11:07 Go to previous message
mirek is currently offline  mirek
Messages: 14262
Registered: November 2005
Ultimate Member
Sometimes it could be useful to test quickly for thread specific id.

For example, if you are incrementing reference count, it seems to be possible to store thread specific id somewhere and then perform non-atomic increment if they match. (Disclaimer: MAYBE. I do not say it is really possible, it is just my current research subject).

Today I have found a nice and simple way how to obtain such id:

__thread int x;

&x is your ID Wink

It is pretty fast too, because TLS pointers are stored in register (in fact, in gs segment on x86).

Mirek
 
Read Message
Read Message
Read Message
Previous Topic: Interesting advantage of using indices instead of iterators
Next Topic: Linear sorted array vs. tree
Goto Forum:
  


Current Time: Fri Jun 27 14:43:19 CEST 2025

Total time taken to generate the page: 0.03128 seconds