__declspec( thread ) Limitations

G

Guest

Hi

Introduction
*********
I am writing a managed profiler using the ICorProfiler*.* API, this involves ceration of an agent DLL loaded by the profiled ( debugee ) process, I need to use TLS to hold some thread specific data

The query
*******
Does using __declspec( thread ) from within the Agent DLL (loaded by the hosting profiled process) ) gurantee that ALL of the threads in the process ( those that were created by the agent and those created be the hosing process ) will have the thread parameter allocated? or should I rather use the Tls*.* Win32 API upon each process creation for TLS initialization

Thanks in advance
Nadav.
 
J

Jochen Kalmbach

=?Utf-8?B?TmFkYXY=?= said:
Hi,

Introduction:
**********
I am writing a managed profiler using the ICorProfiler*.* API, this
involves ceration of an agent DLL loaded by the profiled ( debugee )
process, I need to use TLS to hold some thread specific data.

The query:
********
Does using __declspec( thread ) from within the Agent DLL (loaded by
the hosting profiled process) ) gurantee that ALL of the threads in
the process ( those that were created by the agent and those created
be the hosing process ) will have the thread parameter allocated? or
should I rather use the Tls*.* Win32 API upon each process creation
for TLS initialization?

I suggest NOT to use "__declspec( thread )" because it is NOT supported
if the DLL is delay loaded (for example via "LoadLibrary").

See:
http://msdn.microsoft.com/library/en-us/vclang/html/
_pluslang_the_thread_attribute.asp


Please use
- FlsAlloc (if available) or TlsAlloc
- FlsFree (if available) or TlsFree
- FlsGetValue (if available) or TlsGetValue
- FlsStValue (if available) or TlsSetValue


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top