Community: Wiki

你在这里: You Are Here: Olet tässä: Vous êtes ici: Sie befinden sich hier: Tu sei qui: 現在のページ: Você está aqui: Вы здесь: Usted está aquí:
This page was last modified 13:24, 29 May 2008.

POSIX TLS

From Forum Nokia Wiki

Contents

POSIX TLS

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.

Creating a key

The pthread_key_create() API creates a new key and returns the ID.


Reading from a key

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.


Writing to a key

pthread_setspecific() API can be used to set the value to a key. It takes the ID of the key as argument.


Freeing the key

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.


Links

P.I.P.S

Blogs:: Open C, POSIX, and wheel invention

Blogs:: Study: Open Source POSIX to S60 in Half the Time

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Invite a friend Invite a friend
E-mail Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us Regional websites: Chinese Japanese © 2008 Nokia 
RDF Facets: qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX