Hi all,

How exactly does the function 'DisableThreadLibraryCalls',
found in DllMain under DLL_PROCESS_ATTACH message
of many drivers, help in reducing the size of the
working code set for some applications as stated by msdn ?

regards
sajid

Re: DisableThreadLibraryCalls by Steve

Steve
Mon Aug 30 05:42:34 CDT 2004

It does so by disabling thread library calls! ;-) Every time a thread is
started after a DLL is loaded DllMain is called with a THREAD_ATTACH this is
used to allocate per thread local storage for the DLL. If the DLL doesn't
need any (Typically the case) that overhead can be eliminated.

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups



Re: DisableThreadLibraryCalls by Sajid

Sajid
Mon Aug 30 06:24:26 CDT 2004

Hi Steve,

I have a doubt related to the thread creation in a process
with multiple DLLs loaded in its space.

When a thread is created in this environment,
would kernel notify ALL the DLLs in that process to
allocate TLS[thread local storage for the DLL] for that
thread OR the kernel notifies only the particular DLL for
TLS allocation ?

In case, the kernel notifies all the DLLs in that process,
what is its advantage in doing so, as all the DLLs
may not be used by that thread.

It would be most welcome if you can detail the thread
creation in a process of this environment.

regards
sajid


"Steve Maillet (eMVP)" <nospam1@EntelechyConsulting.com> wrote in message
news:O0Z5d4njEHA.632@TK2MSFTNGP12.phx.gbl...
> It does so by disabling thread library calls! ;-) Every time a thread is
> started after a DLL is loaded DllMain is called with a THREAD_ATTACH this
is
> used to allocate per thread local storage for the DLL. If the DLL doesn't
> need any (Typically the case) that overhead can be eliminated.
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
>
> Do have an opinion on the effectiveness of Microsoft Windows Mobile and
> Embedded newsgroups? Let us know!
> https://www.windowsembeddedeval.com/community/newsgroups
>
>



Re: DisableThreadLibraryCalls by Steve

Steve
Mon Aug 30 08:21:16 CDT 2004

The kernel notifies ALL Dlls unless the dll called
DisableThreadLibraryCalls(). The system cannot know if a thread will or
won't use the functions of a particular DLL so it MUST call DllMain For each
thread unless told not to for all threads. The advantage of
DisableThreadLibraryCalls() is that it can mark the DLL to skip this process
for most DLLs as it is not needed most of the time saving the overhead.

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups