473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

__declspec( thread ) Limitations

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.
Nov 17 '05 #1
1 3133
=?Utf-8?B?TmFkYXY=?= wrote:
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/
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Patrick Hoffmann | last post by:
hi folx, today I had "multithreading" trouble with the following code (MS VC++6/optimized compiling): --------------------------- class myclass { static int s_nNext; public:
4
by: JustSomeGuy | last post by:
I had written a debugging/trace loggin class that l have been using to test and develope my applications... At first the application was tested and ran as a single thread, with all output going to...
6
by: Shai Levi | last post by:
Hi, I'm trying to migrate native c++ class to managed c++ class. The native class header definition looks as: class NativeClass { public: typedef void (CbFunc1)(int n,void* p);
1
by: Boris | last post by:
With MFC Extension DLL that exports classes through __declspec(dllexport) DLL_PROCESS_ATTACH/DLL_PROCESS_DETACH 1. Does each a process loads dll only once and unloads dll only once during its...
3
by: Gustavo L. Fabro | last post by:
Greetings! I'm a newbie in Visual C++ .NET (have programmed in Borland C++ and Builder for long) and I am trying to do a very simple thing, but I'm stuck. I created an (unmanaged) DLL project...
1
by: kkubio | last post by:
Hi all, I'd like some advice on adding an extended stored procedure (XP). I found an article which advises "put the call of the extended prodecure within a database procedure in the database from...
4
by: =?Utf-8?B?UmljaGFyZCBNU0w=?= | last post by:
I have a legacy project with hundreds of unmanaged C programs, that I am porting to .NET. There are a lot of globally scoped variables in the C programs, which I have had to convert to thread...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: =?UTF-8?B?Q2hyaXN0aWFuIFLDtnNzZWw=?= | last post by:
An object of struct TLS should be thread-local: struct Foo {}; struct TLS { Foo* a; bool b; }; __declspec(thread) TLS MyTLS;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.