Skip to content

Commit

Permalink
Introduced a clientlock on Linux / OS X, as we have on windows.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@4189 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Otto Tronarp committed Aug 31, 2009
1 parent 9da5730 commit 3685564
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Compiler/runtime/corbaimpl.cpp
Expand Up @@ -325,10 +325,13 @@ extern "C" {
using namespace std;

pthread_mutex_t lock;
pthread_mutex_t clientlock;

// Condition variable for keeping omc waiting for client requests
pthread_cond_t omc_waitformsg;
pthread_mutex_t omc_waitlock;
bool omc_waiting=false;

// Condition variable for keeping corba waiting for returnvalue from omc
pthread_cond_t corba_waitformsg;
pthread_mutex_t corba_waitlock;
Expand Down Expand Up @@ -373,6 +376,7 @@ RML_BEGIN_LABEL(Corba__initialize)
pthread_cond_init(&corba_waitformsg,NULL);
pthread_mutex_init(&corba_waitlock,NULL);
pthread_mutex_init(&omc_waitlock,NULL);
pthread_mutex_init(&clientlock, NULL);

#if defined(USE_OMNIORB)
orb = CORBA::ORB_init(argc, dummyArgv, "omniORB4");
Expand Down
8 changes: 6 additions & 2 deletions Compiler/runtime/omc_communication_impl.cpp
Expand Up @@ -96,6 +96,8 @@ extern "C" {
#include <pthread.h>
}

extern pthread_mutex_t clientlock;

extern pthread_cond_t omc_waitformsg;
extern pthread_mutex_t omc_waitlock;

Expand All @@ -119,6 +121,7 @@ OmcCommunication_impl::OmcCommunication_impl()

char* OmcCommunication_impl::sendExpression( const char* expr )
{
pthread_mutex_lock(&clientlock);
char* result;
// Signal to omc that message has arrived.
pthread_mutex_lock(&omc_waitlock);
Expand All @@ -133,9 +136,10 @@ char* OmcCommunication_impl::sendExpression( const char* expr )
pthread_cond_wait(&corba_waitformsg,&corba_waitlock);
}
corba_waiting = false;
result = CORBA::string_dup(omc_reply_message);
pthread_mutex_unlock(&corba_waitlock);

return CORBA::string_dup(omc_reply_message); // Has already been string_dup (prepared for CORBA)
pthread_mutex_unlock(&clientlock);
return result; // Has already been string_dup (prepared for CORBA)
}

char* OmcCommunication_impl::sendClass( const char* expr )
Expand Down

0 comments on commit 3685564

Please sign in to comment.