Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-06-05 13:29:01 +0000
committerHenrik Rentz-Reichert2013-06-05 13:29:01 +0000
commitaec457748f8c5bd807978e3d07eaa49eb618acb5 (patch)
tree798c3208421d76a2851961a144301e1ec9efb7e3 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent272815ea1a816569edc6629ca4f2db8e874100cc (diff)
downloadorg.eclipse.etrice-aec457748f8c5bd807978e3d07eaa49eb618acb5.tar.gz
org.eclipse.etrice-aec457748f8c5bd807978e3d07eaa49eb618acb5.tar.xz
org.eclipse.etrice-aec457748f8c5bd807978e3d07eaa49eb618acb5.zip
[runtime.c] still debugging...
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c33
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTcpSockets.c2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c15
5 files changed, 44 insertions, 11 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
index 81f5d89b9..fab2d8e15 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
@@ -93,7 +93,7 @@ typedef int16 etAddressId;
typedef pthread_mutex_t etOSMutexData;
typedef pthread_t etOSThreadData;
-typedef pid_t etOSThreadId;
+typedef pthread_t etOSThreadId;
typedef sem_t etOSSemaData;
typedef struct {
void* next;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
index 94213f4ec..81f040b2a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
@@ -16,6 +16,8 @@
*
*/
+#include <errno.h>
+
#include "osal/etSema.h"
#include "etDatatypes.h"
@@ -38,12 +40,39 @@ void etSema_destruct(etSema* self){
void etSema_wakeup(etSema* self){
ET_MSC_LOGGER_SYNC_ENTRY("etSema", "wakeup")
- sem_post(&(self->osData));
+ {
+ int sval = 0;
+ sem_getvalue(&(self->osData), &sval);
+ printf("etSema_wakeup: %p before post val=%d\n", (void*)self, sval);
+ sem_post(&(self->osData));
+ sem_getvalue(&(self->osData), &sval);
+ printf("etSema_wakeup: %p after post val=%d\n", (void*)self, sval);
+ fflush(stdout);
+ }
ET_MSC_LOGGER_SYNC_EXIT
}
void etSema_waitForWakeup(etSema* self){
ET_MSC_LOGGER_SYNC_ENTRY("etSema", "waitForWakeup")
- sem_wait(&(self->osData));
+ {
+ int again = FALSE;
+
+ printf("etSema_waitForWakeup: %p wait %ld\n", (void*)self, pthread_self()); fflush(stdout); // TODO: remove debug output
+ do {
+ errno = 0;
+ if (sem_wait(&(self->osData))==-1) {
+ if (errno==EINTR) {
+ int sval = 0;
+ sem_getvalue(&(self->osData), &sval);
+ again = FALSE;
+ printf("etSema_waitForWakeup: %p interrupted - again %ld (val=%d)\n", (void*)self, pthread_self(), sval); fflush(stdout); // TODO: remove debug output
+ }
+ else
+ again = FALSE;
+ }
+ }
+ while (again);
+ printf("etSema_waitForWakeup: %p waked up %ld\n", (void*)self, pthread_self()); fflush(stdout); // TODO: remove debug output
+ }
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTcpSockets.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTcpSockets.c
index cd2fbbf8f..b2968278e 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTcpSockets.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTcpSockets.c
@@ -88,7 +88,7 @@ static void listenerThreadFunc(void* threadData) {
while (self->data.maxConnections > self->nConnections) {
int slot;
- int len;
+ socklen_t len;
/* find next free slot */
for (slot=0; slot<MAX_CONNECTIONS; ++slot)
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 95fc528da..f40bc385e 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
@@ -21,7 +21,6 @@
#include "debugging/etLogger.h"
#include "debugging/etMSCLogger.h"
-#include <process.h>
#include <time.h>
#include <sys/unistd.h>
@@ -108,6 +107,6 @@ etOSThreadData etThread_self(void){
}
etOSThreadId etThread_self_id(void){
- return 0;
+ return pthread_self();
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
index 7dba99ffd..9e857a336 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
@@ -54,7 +54,7 @@ static etBool timer_initialized = FALSE;
static etThread timer_thread;
-/* semaphore used for signalling */
+/* semaphore used for signaling */
static etSema timer_sema;
/* mutex to guard linked list access */
@@ -63,6 +63,7 @@ static etMutex timer_mutex;
static void timerThreadFunction(void* data) {
while (TRUE) {
etTimer* it;
+ int idx;
printf("timerThreadFunction: waiting\n"); fflush(stdout); // remove debug output
etSema_waitForWakeup(&timer_sema);
@@ -70,11 +71,11 @@ static void timerThreadFunction(void* data) {
printf("timerThreadFunction: checking\n"); fflush(stdout); // remove debug output
etMutex_enter(&timer_mutex);
- for (it=timers; it!=NULL; it=(etTimer*) it->osTimerData.next) {
+ for (it=timers, idx=0; it!=NULL; it=(etTimer*) it->osTimerData.next, ++idx) {
if (it->osTimerData.signaled) {
+ printf("timerThreadFunction: signaled %d, calling user fct %p\n", idx, (void*)it->timerFunction); fflush(stdout); // remove debug output
it->osTimerData.signaled = FALSE;
it->timerFunction(it->timerFunctionData);
- printf("timerThreadFunction: signaled\n"); fflush(stdout); // remove debug output
}
}
etMutex_leave(&timer_mutex);
@@ -90,9 +91,12 @@ static void timerHandler(int sig, siginfo_t *si, void *uc) {
etMutex_enter(&timer_mutex);
for (it=timers; it!=NULL; it=(etTimer*) it->osTimerData.next) {
if (&it->osTimerData.timerid==tid) {
+ int sval = 0;
+ sem_getvalue(&(timer_sema.osData), &sval);
it->osTimerData.signaled = TRUE;
- etSema_wakeup(&timer_sema);
- printf("timerHandler\n"); fflush(stdout); // TODO: remove debug output
+ if (sval==0)
+ etSema_wakeup(&timer_sema);
+ printf("timerHandler signaled\n"); fflush(stdout); // TODO: remove debug output
break;
}
}
@@ -163,6 +167,7 @@ void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction tim
fflush(stderr);
return;
}
+ printf("etTimer_construct: user callback is %p\n", (void*)self->timerFunction); fflush(stdout); // TODO: remove debug output
}
}
ET_MSC_LOGGER_SYNC_EXIT

Back to the top