Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
index 30d920a5b..cb4beb29a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
@@ -23,6 +23,7 @@
#include <time.h>
#include <sys/unistd.h>
+#include <errno.h>
typedef void *(*threadFunc)(void *);
void* etThread_execute(etThread* self);
@@ -91,13 +92,16 @@ void etThread_sleep(etInt32 millis){
ET_MSC_LOGGER_SYNC_ENTRY("etThread", "sleep")
{
/* TODO: nanosleep doesn't work at all */
-/* struct timespec time; */
-/* time.tv_nsec = 1000*1000*millis; */
-/* time.tv_sec = 0; */
-/* nanosleep(&time, NULL); */
- if (millis<1000)
- millis = 1000;
- sleep(millis/1000);
+ struct timespec time;
+ time.tv_sec = millis / 1000;
+ time.tv_nsec = (millis - time.tv_sec * 1000) * 1000*1000;
+ while(nanosleep(&time, &time) != 0) {
+ if(errno != EINTR)
+ break;
+ }
+// if (millis<1000)
+// millis = 1000;
+// sleep(millis/1000);
}
ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top