Article View: borland.public.cppbuilder.nativeapi
Article #6011Re: Info sought on thread local storage (TLS)
From: Bob Gonder
Date: Thu, 16 Jun 2005 16:33
Date: Thu, 16 Jun 2005 16:33
30 lines
2202 bytes
2202 bytes
Ed Mulroy wrote: >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. Um, yeah, if you go in and trash the place, sure.. but the TLS example code shows the thread doing LocalAlloc (which can be any size) and 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. > If you Win32 function to start the thread in a C/C++ program then >you also risk causing a crash. That one didn't parse? CreateThread()? Crashing?
Technical Details
Message-ID:
<k793b199hfec1r2m45invvdv5emo2crudd@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42b0a9ef.20026212@forums.borland.com> <42b0b9b5@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fe9ab360edfd8d88 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Info sought on thread local storage (TLS) Date: Thu, 16 Jun 2005 09:33:24 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <k793b199hfec1r2m45invvdv5emo2crudd@4ax.com> References: <42b0a9ef.20026212@forums.borland.com> <42b0b9b5@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.109.182 X-Trace: newsgroups.borland.com 1118939603 67.77.109.182 (16 Jun 2005 09:33:23 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail