newlib: Initial thread-safe implementation#4529
newlib: Initial thread-safe implementation#4529DipSwitch wants to merge 2 commits intoRIOT-OS:masterfrom
Conversation
|
Fixes: #4488 |
3f53d58 to
27bcae9
Compare
|
The code looks sane to me. I guess you have not yet looked at code sizes, right? Especially the memory increase for the tcb would be interesting to know... Though in general I would say that we don't enable this feature per default and try to get the newlib 'thread-safe-enough' with other means (e.g. actively blocking or buffering UART for puts/printf) to safe memory and task switching overheads, but this is also something we would need to benchmark to make some informed decisions... |
|
Yep, please update tests/sizeof_tcb/main.c. |
|
Fixed compile problems and included it in Please note that it would also be possible to make the reent implementation thread specific by using a pointer to |
|
@haukepetersen the code in newlib is already called, the only difference now is that newlib doesn't use a global struct but a thread specific struct. So no penalties are to be expected. |
cpu/Makefile.include.cortexm_common
Outdated
There was a problem hiding this comment.
This needs to be removed before merging and another method needs to be found to enable thread-safety.
There was a problem hiding this comment.
I restore this line and make the application include it using the pseudo module?
I am not so sure about that. We have this newlib struct the as part of every tcb, so the tcp size increases, right? Did you do some initial measurements on the changes in code/ram usage? |
|
Any news? |
|
The reentry struct is 96 bytes / 24 words total :) |
|
@DipSwitch So, that is the cost per thread to implement thread safe |
|
Yup :)
|
|
I tried this PR very briefly and I get hard faults on mulle during startup in the xtimer_drift test application and a plain lockup on stm32f4discovery. The stm32 is stuck inside sched_run with an empty runqueue. The program runs up to the first Below is my quick debug dump from the stm32f4discovery board: |
|
Any news? |
|
ping @DipSwitch |
|
I looked yesterday and have a fix the crash. But then I noticed the stack Maybe instead of using -O0 this can be solved using -Og although I don't
|
|
@DipSwitch no rush, could you push your updated branch to Github? |
|
Hmm false positive... And sorry about the stray commits, will fix later. I don't know where the previous statement of 96 bytes is comming from. Maybe it got something to do with an optimalization which came with using |
| endef | ||
|
|
||
| # compile the tests | ||
| __has_reent := $(shell echo "\#include <sys/reent.h>\n" | $(CC) -E $(CFLAGS) $(INCLUDES) - 2> /dev/null > /dev/null; echo $$?) |
There was a problem hiding this comment.
the \n results in an error: "stdin>:1:23: error: extra tokens at end of #include directive [-Werror]", adding -e to the echo command solves it ( -e: enable interpretation of backslash escapes)
There was a problem hiding this comment.
echo is really the worst way to get a text string in shell scripts. There
is no standard specification and the flags and default behaviour differ
between almost every platform (OSX, Linux, BSD, windows etc.)
Also, the \n is redundant since echo will add a newline to the string (on
all platforms that I know of) when called with no flags.
Den 23 aug. 2016 09:52 skrev "Pieter Willemsen" [email protected]:
In sys/newlib/thread_safe/Makefile.include
#4529 (comment):
@@ -0,0 +1,22 @@
+# define the compile test file
+define __has_reent_small_test
+#include <sys/reent.h>\n
+#ifndef _REENT_SMALL\n
+#error wasting 1KB\n
+#endif
+endef
+
+# compile the tests
+__has_reent :=$(shell echo "#include <sys/reent.h>\n" | $ (CC) -E$(CFLAGS) $ (INCLUDES) - 2> /dev/null > /dev/null; echo $$?)
the \n results in an error: "stdin>:1:23: error: extra tokens at end of
#include directive [-Werror]", adding -e to the echo command solves it (
-e: enable interpretation of backslash escapes)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/RIOT-OS/RIOT/pull/4529/files/0b380225290d6b1efeea9a7bbb273684b417672d#r75816861,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATYQu8sumUmNCJsn-omBi-6etbn_ofjks5qiqa9gaJpZM4G43Px
.
|
I don't see why this is marked as a bug (except if you see |
|
Any progress here? |
|
postponed 4 times in the past, removing milestone label. |
|
No significant progress for over a year. Closing as memo for now. |
This is the initial implementation to make newlib thread safe.
Things that could be changed:
struct reentto thetcb_tbut a pointer where we set the global pointer if the user doesn't want to make it thread-safeI haven't tested yet if it compiles.