OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Aug 12, 2020 6:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Thread Local Storage
PostPosted: Mon Nov 17, 2014 5:33 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
Hi,

I wrote a wiki article on Thread Local Storage on System V ABI platforms using the __thread keyword. It contains information on how the ABI works, links to more information, and advise on how to implement this yourself. I also put up notes on how I do this in my operating system as a more concrete example.

It's a bit of a rough draft, do let me know if you find this interesting or have suggestions for improvement.

It needs to be linked to from some other pages, not sure which ones are related.

Share and Enjoy!


Top
 Profile  
 
 Post subject: Re: Thread Local Storage
PostPosted: Tue Nov 18, 2014 1:23 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
Sortie,

sortie wrote:
[...] or have suggestions for improvement.


Great article. I'm sure I will be referencing it in the future.

My comments are more about readability than content. These are just a couple of things that jump off a page at me and since this is a new article, I thought I would offer my opinion.

You use the acronym "TLS" here without explicitly defining its meaning at the top of the wiki. It actually took me a moment to figure out what TLS stood for. :oops:

Also, you use "TLS" in upper case as well as "tls" in lower case in the same section. I would suggest being consistent.

_________________
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber


Top
 Profile  
 
 Post subject: Re: Thread Local Storage
PostPosted: Tue Nov 18, 2014 2:30 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
Thanks. :)

It's now fixed: I defined TLS in the first sentence and made the rest of the article more consistent by spelling it out most of the time.


Top
 Profile  
 
 Post subject: Re: Thread Local Storage
PostPosted: Wed Nov 19, 2014 2:22 am 
Offline
Member
Member
User avatar

Joined: Mon Mar 05, 2012 11:23 am
Posts: 606
Location: Germany
sortie wrote:
Thanks. :)

It's now fixed: I defined TLS in the first sentence and made the rest of the article more consistent by spelling it out most of the time.

Thanks for writing that article sortie! :)
I'll implement TLS in my kernel once I'm healthy again.

P.S.: on this occasion I'll also check if you're stuff is austypogehaftet to see if it's all fine.
:mrgreen: <3

_________________
Ghost OS - GitHub


Top
 Profile  
 
 Post subject: Re: Thread Local Storage
PostPosted: Sat Nov 22, 2014 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed May 15, 2013 5:49 pm
Posts: 44
Location: Berlin
Sortie,

Thanks for writing all that. Tremendously helpful not just for OS dev, but also for standard C library implementation.

_________________
Developer of libc11


Top
 Profile  
 
 Post subject: Re: Thread Local Storage
PostPosted: Fri Mar 06, 2015 4:04 pm 
Offline
Member
Member
User avatar

Joined: Mon Mar 05, 2012 11:23 am
Posts: 606
Location: Germany
Finally implemented TLS in Ghost today. Thanks a lot again sortie.

I have a question though, you use this calculation for the alignment:
Code:
max(master_tls_alignment, alignof(struct uthread));
This confused me a little trying to figure out how to align the address of the location that contains the self-pointer (and therefore the location of the user-thread-struct) properly. What if the alignment of the TLS was 4, but the alignment of the user-thread struct was 8 - wouldn't the location that contains the self-pointer of the user-thread struct be set off by 4 bytes too much?

Also, I made this little visualization, is it correct & maybe helpful for the wiki?

Image

_________________
Ghost OS - GitHub


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group