Interesante, siempre me pregunté para que %$")%$"%/(&·)&·()%· servía eso de TLS. Matt Dillon lo sabe explicar de una manera bastante comprensible:
TLS stands for 'thread local storage'. It is a way of abstracting
global variable declarations that you want to be 'per thread' storage
rather then common storage.
so, e.g. in a threaded environment, if you declare a global variable:
int Fubar;
Then that global variable will represent the same storage across all threads.
But if you declare it:
__thread int Fubar;
Then each thread will be given *different* storage for Fubar.
This feature could be used by, well, just about every library. For example,
it would allow us to clean up how 'errno' works in a threaded environment.
It would allow standard libc calls such as ctime() and localtime() work
properly in a threaded environment, and it would greatly simplify the job
of writing threaded library code.
15 de marzo de 2005
__thread
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario