Computer Scientist

Sunday, 21 October 2012

Thread-local storage

Thread-local storage (TLS) is a programming method that is used to make static and global variables be local to a thread. The '"errno" is a canonical example of TLS method. Actually, a "errno" should be a static variable used by all functions to determine the error status. However, in each thread of a running process, there should be a separated one in order to prevent the infection from other threads in the same process.

The comparing method to achieve the similar function with the TLS is the thread lock for a static or global variable. However, a carelessness of requiring the lock in any threads in the process would affect other threads.

No comments:

Post a Comment