Using thread local variables instead of the global ones

Szekeres Tamás szekeres.tamas at FREEMAIL.HU
Thu Apr 27 19:31:12 EDT 2006


Developers,

 

According to the IRC conversation with Frank I would like to get to know the
developer's affinity of this issue.

 

So it would be worth considering to make a support for using thread local
variables instead of the global ones in the mapserver code.

1. It would add a significal increment on the performace of the applications
having high number of multiple threads simultaneously.

2. This activity could bring in a more feasible support for some application
models not really supported now like Microsoft ASP.NET

3. May result in higher clarity of the code by determining the variables
affected by multiple threads.

 

The main drawback of this proposal is the need of to look over most of the
existing code.

 

Frank has already worked on a solution targeting this problem for GDAL to
utilize the Win32 TLS API and the Pthreads implementation.

 

In addition I would suggest to rely on the strorage specifiers existing for
many of the platforms. It would be quite an easy to integrate into the

existing code, like: 

 

#ifdef USE_THREAD_LOCALS

#ifdef WIN32

#define MS_TLS __declspec( thread )

#endif

#ifdef __unix

#define MS_TLS __thread

#endif

#else

#define MS_TLS

#endif

 

 

For declaring a thread local variable we could use:

 

static MS_TLS YY_BUFFER_STATE yy_current_buffer = 0;

 

Any of theese changes would imply some additional tests for the different
platforms.

 

For additional information I would refer to

http://en.wikipedia.org/wiki/Thread-local_storage

 

Any comment would be appreciated

 

Tamas Szekeres

 


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.5.1/326 - Release Date: 2006.04.27.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20060428/c9c713c3/attachment.html


More information about the mapserver-dev mailing list