Board index » cppbuilder » Info sought on thread local storage (TLS)
hgiese
![]() CBuilder Developer |
hgiese
![]() CBuilder Developer |
Info sought on thread local storage (TLS)2005-06-16 06:27:41 AM cppbuilder52 Hello out there, while I am familiar with writing multi-threaded apps, the concept of thread local storage (TLS) is rather unknown to me. Now it appears that the time has come where I will have to use this feature, so I am looking for some sort of a general overview on TLS (hopefully providing some examples). Any links will be greatly appreciated. Best regards Helmut Giese |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2005-06-16 06:54:24 AM
Re:Info sought on thread local storage (TLS)
"Helmut Giese" < XXXX@XXXXX.COM >wrote in message
Quotewhile I am familiar with writing multi-threaded apps, the concept to worry about working with TLS, especially if you have classes wrapping thread objects for you, such as the VCL's TThread class. QuoteNow it appears that the time has come where I will have to use this |
Ed Mulroy
![]() CBuilder Developer |
2005-06-16 07:28:51 AM
Re:Info sought on thread local storage (TLS)
Warning:
Thread Local Storage, TLS, provides a very small amount of memory. Every compiler supplies an alternate function to that provided by Win32 for starting a thread. The compiler-supplied function(s) set up a data block and place the address of that block and possibly some flags into the TLS memory. If you alter TLS memory you may crash the program and possibly crash the machine. If you Win32 function to start the thread in a C/C++ program then you also risk causing a crash. . Ed QuoteHelmut Giese wrote in message {smallsort} |
hgiese
![]() CBuilder Developer |
2005-06-16 06:47:39 PM
Re:Info sought on thread local storage (TLS)
Hi Ed,
QuoteWarning: Quote
things can be simplified. Thanks for the alert and best regards Helmut Giese |
hgiese
![]() CBuilder Developer |
2005-06-16 06:49:00 PM
Re:Info sought on thread local storage (TLS)
Hi Gambit,
QuoteBasically, an API thread object has an array available where applications Helmut Giese |
Bob Gonder
![]() CBuilder Developer |
2005-06-17 12:33:24 AM
Re:Info sought on thread local storage (TLS)
Ed Mulroy wrote:
QuoteWarning: placing the pointer into TLS. So, you don't actually mess with TLStorage, just the LocalAlloc buffer. Only advantage I see is the thread doesn't have to pass the pointer to all of it's subroutines. Oh, perhaps you were warning that VCL and perhaps TThread already use that slot, and overwritting it would be problematic? So, one should ensure TlsGetValue() == 0 before TlsSetValue(), at least for testing purposes. QuoteIf you Win32 function to start the thread in a C/C++ program then |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2005-06-17 01:57:42 AM
Re:Info sought on thread local storage (TLS)
"Helmut Giese" < XXXX@XXXXX.COM >wrote in message
QuoteHuh? Doesn't sound exactly promising. Then you can put whatever you want into the class. TLS is typiucally only used by the OS for its own internal uses (storing COM thread concurrency flags, GetLastError() error codes, etc). Gambit |
hgiese
![]() CBuilder Developer |
2005-06-17 05:17:08 PM
Re:Info sought on thread local storage (TLS)QuoteWhat exactly are you trying to accomplish in the first place? Typically, will handle the main program while each interrupt service routine will get its own thread, so that they can interrupt each other "like in the real world". The whole concept is still somewhat misty and at one point in time I thought I might need TLS - or rather learn enough about TLS to be able to judge whether it would be helpful here. The problematic part for the moment is that all these threads will do some reporting (we want to know what's going one) and this is the bottleneck right now: they can (and will) interrupt each other there and I want a robust design which can be carried over to "Version 2" (when we add simulating an RTOS - Real Time OS - on top of this). We'll just leave it at this point for the moment. I'm at the drawing board drawing little pictures ... Best regards Helmut Giese |