-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys:posix:pthread added dynamic pthread thread local storage #1222
Conversation
Please note that the overhead of malloc must not be neglected. Compare #827, which implements the feature differently. |
absolutely. I know, this implementation is a bit naive. |
ok, added destructor and cleanup calls, cleaned up formatting and rebased on current master |
return -1; | ||
} | ||
|
||
sched_switch(sched_active_thread->priority, PRIORITY_MAIN); | ||
sched_switch (sched_active_thread->priority, PRIORITY_MAIN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astyle
Granted, your implementation looks easier on the eyes than mine. I'll give it a proper review. |
|
||
|
||
/** @} */ | ||
#endif /* __SYS__POSIX__PTHREAD_TLS__H */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swap these last two lines.
reverted astyle code styling to apply it when finished |
|
This is one point where I'm undecided. and further (only destructor function related but fitting): |
The key becomes invalid, non-existent. To single thread the pointer that it stored in there is lost, essentially because an invalid key cannot be used to look up the value again. |
ok, but for That's the reason why I made BytesGalore@e33c649 (tracking number of pthreads using a specific key) |
E.g. Dietlibc interprets it like I do: https://github.com/ensc/dietlibc/blob/master/libpthread/pthread_key.c. |
true, tracking and keeping the keys was not the expected behaviour. I propose to delete the key and only this thread's data, and let the |
3a7e57d
to
148c72b
Compare
64d53ae
to
7e462ff
Compare
7e462ff
to
e7a6f21
Compare
d274ffd
to
bfcc273
Compare
bfcc273
to
3d50162
Compare
We didn't look at it IIRC. I have nob objections against merging. |
Maybe @josephnoir wants to review/ack/comment? |
3d50162
to
ae75123
Compare
ae75123
to
855f1b2
Compare
Looked at the code, looks good and the test compiles and runs. However, I believe the test name is outdated? |
@josephnoir like naming the test without test prefix right? |
@josephnoir renamed the test, will squash when travis succeeds |
5379e1f
to
6e90ad6
Compare
squashed |
@ALL: please do not remove your assignment without reassigning - if you don't know (or don't care) who to assign, just pick me (or whoever comes first). |
Everything seems to work, so here we go: sys:posix:pthread added dynamic pthread thread local storage
added a dynamic tls implementation to
pthread.c
This is an alternative approach to #827
The impact is additional 4 bytes per
pthread_thread_t
when not used.If used, 12 bytes for each key and additional 12 bytes for each tls is consumed.