Contents |
TLS(Thread Specific Data or Thread Local Storage) is memory area that is specific to that particular thread.Any kind of DLL or exe can use this.
TLS is provided in chunks of 4 bytes. Each such 4 bytes of chunk is called a key. If a program needs TLS, then it has to create a key. Once a key is created, an ID (handle) is returned. And this ID should be used to read and write to the key.
The following APIs which are part of libpthread describes briefly how to create,read,write and free a key.
The pthread_key_create() API creates a new key and returns the ID.
The pthread_getspecific() API can be used to read the value of the key. Here, it takes the ID of the key as an argument.
pthread_setspecific() API can be used to set the value to a key. It takes the ID of the key as argument.
The pthread_key_delete() API deletes the key in all the threads. Once the key is deleted, no thread should use the old handle/ID to set and get the key value.
If a thread is created after the key is created, then the key is available in the new thread from the beginning.
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How can I get the local IP allocated to my 6630 | EranNoyman | General Symbian C++ | 8 | 2006-10-19 14:26 |
| Dll::Tls可以代替全局变量的使用??? | tangl_99 | Symbian | 1 | 2005-09-05 09:57 |
| A question about using Dll::SetTls() in SDK, can someone help me? | steve.sun | General Symbian C++ | 4 | 2007-06-12 08:24 |
| linker error ..Please help me...Urgent | lakshmi.prasanna | General Symbian C++ | 1 | 2005-10-19 14:53 |
| Is it possible to port a symbian engine to pc application? | nyamgasoft | Open C | 1 | 2008-08-21 14:08 |