LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-28-2006, 07:32 AM   #1
chlimouj
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Rep: Reputation: 0
new to multithreaded programming... why is TLS needed?


I'm new to threaded programming on Linux, and I've been reading a lot about the advancements in pthreads in the past couple years, but one thing I've been wondering is what is the big deal about thread-local storage?

Yes, I understand it is important for threads to be able to have their own local variables untouchable by other threads, but why can't this be implemented with just a malloc/free or new/delete? In both cases, the call is guaranteed to reserve a new memory location. I've actually implemented this in a little server I'm writing, and I have yet to see any adverse side effects... I've hammered it with several simulaneous connections and observed as many as 15 threads running concurrently (on a dual cpu system), and I did not notice any concurrency issues or memory overlapping.

So... why the TLS? Why deal with creating keys and pthread_getspecific, etc? Am I wrong in my understanding of what TLS is supposed to do?

-JC
 
Old 08-30-2006, 06:56 AM   #2
sooty
LQ Newbie
 
Registered: Nov 2002
Location: birmingham england
Distribution: Gentoo
Posts: 26

Rep: Reputation: 15
Im no expert but local variables are allocated from the stack and using malloc and new allocates from heap.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming text editor needed cupoftea Linux - Software 10 05-24-2006 09:48 AM
Kernel Programming help needed arunka Linux - General 1 03-01-2005 05:53 AM
c++ file i/o programming help needed rajorshi Linux - Newbie 1 09-13-2003 01:40 PM
PCI programming help needed sarin Programming 2 09-01-2002 04:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration