Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2016-09-28 05:35:20 -0400
committerJan Belle2016-09-29 09:17:02 -0400
commit73efe3ca6ebe2b580e5847b728b8088cba35cc2d (patch)
tree87f8894c0e5900f6fc0aab14820281c692a8c96c /runtime
parent22b8e8c7c55e06c6fa040b594bc56f18390b5af8 (diff)
downloadorg.eclipse.etrice-73efe3ca6ebe2b580e5847b728b8088cba35cc2d.tar.gz
org.eclipse.etrice-73efe3ca6ebe2b580e5847b728b8088cba35cc2d.tar.xz
org.eclipse.etrice-73efe3ca6ebe2b580e5847b728b8088cba35cc2d.zip
[runtime.cpp.tests] Initial commit of MessageServiceTest
[runtime.cpp] Changed mutex_leave position in MessageServiceController::terminate() method Changed m_running set to true in MessageService::start() instead of MessageService::run() Fixed double delete of the MessageDispatcher and MessageSeQueue in AbstractMessageService [runtime.c] Changed etThread_sleep(int millis) from using sleep to nanosleep for Linux_Posix Change-Id: Ieccbfebea4eec6c2104a8356fb7948f0f3c3510c Signed-off-by: Jan Belle <jan.belle@protos.de>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp2
4 files changed, 15 insertions, 12 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
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp
index a52351d1b..e8b587735 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp
@@ -18,8 +18,8 @@ namespace etRuntime {
AbstractMessageService::AbstractMessageService(IRTObject* parent, const std::string& name, int node, int thread) :
RTObject(parent, name),
m_address(node, thread, 0),
- m_messageQueue(this, "Queue"),
- m_messageDispatcher(this, m_address.createInc(), "Dispatcher") {
+ m_messageQueue(NULL, "Queue"),
+ m_messageDispatcher(NULL, m_address.createInc(), "Dispatcher") {
}
Address AbstractMessageService::getFreeAddress() {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
index b6ef64a55..e2d74934c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
@@ -67,7 +67,6 @@ void MessageService::MessageService_init(etTime interval, int priority) {
}
MessageService::~MessageService() {
- std::cout << "~MessageService" << std::endl;
etMutex_destruct(&m_mutex);
etSema_destruct(&m_executionSemaphore);
etThread_destruct(&m_thread);
@@ -77,6 +76,7 @@ MessageService::~MessageService() {
}
void MessageService::start() {
+ m_running = true;
etThread_start(&m_thread);
if (m_execMode == IMessageService::POLLED || m_execMode == IMessageService::MIXED) {
etTimer_start(&m_timer);
@@ -84,7 +84,6 @@ void MessageService::start() {
}
void MessageService::run() {
- m_running = true;
while (m_running) {
etMutex_enter(&m_mutex);
const Message* msg = getMessageQueue().pop(); // get next Message from Queue
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
index f6af90682..89ab179b4 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -112,13 +112,13 @@ void MessageServiceController::terminate() {
// terminate all message services
etMutex_enter(&m_mutex);
m_terminateServices = m_messageServices;
- etMutex_leave(&m_mutex);
std::map<int, IMessageService*>::iterator it = m_terminateServices.begin();
for (; it != m_terminateServices.end(); ++it) {
(it->second)->terminate();
//TODO TS: stop in order of priorities
}
+ etMutex_leave(&m_mutex);
}
void MessageServiceController::waitTerminate() {

Back to the top