Browse Source

Revert "encapsulate fcn calls to cp_evloop into a mutex"

This reverts commit 2426a037db.
pre-master-46
Holger Vogt 7 years ago
parent
commit
cf752bf730
  1. 24
      src/sharedspice.c

24
src/sharedspice.c

@ -10,7 +10,7 @@
/*******************/ /*******************/
#ifdef _MSC_VER #ifdef _MSC_VER
#define SHAREDSPICE_version "31.0"
#define SHAREDSPICE_version "30.0"
#define STDIN_FILENO 0 #define STDIN_FILENO 0
#define STDOUT_FILENO 1 #define STDOUT_FILENO 1
#define STDERR_FILENO 2 #define STDERR_FILENO 2
@ -276,7 +276,6 @@ unsigned int main_id, ng_id, command_id;
mutexType triggerMutex; mutexType triggerMutex;
mutexType allocMutex; mutexType allocMutex;
mutexType fputsMutex; mutexType fputsMutex;
mutexType evloopMutex;
#endif #endif
/* initialization status */ /* initialization status */
@ -336,11 +335,8 @@ _cthread_run(void *controls)
pthread_mutex_unlock(&triggerMutex); pthread_mutex_unlock(&triggerMutex);
#endif #endif
fl_exited = FALSE; fl_exited = FALSE;
for (wl = controls; wl; wl = wl->wl_next) {
mutex_lock(&evloopMutex);
for (wl = controls; wl; wl = wl->wl_next)
cp_evloop(wl->wl_word); cp_evloop(wl->wl_word);
mutex_unlock(&evloopMutex);
}
fl_exited = TRUE; fl_exited = TRUE;
#ifdef HAVE_LIBPTHREAD #ifdef HAVE_LIBPTHREAD
cont_condition = FALSE; cont_condition = FALSE;
@ -358,9 +354,7 @@ _thread_run(void *string)
if (!nobgtrwanted) if (!nobgtrwanted)
bgtr(fl_exited, ng_ident, userptr); bgtr(fl_exited, ng_ident, userptr);
// bgtid = thread_self(); // bgtid = thread_self();
mutex_lock(&evloopMutex);
cp_evloop((char *)string); cp_evloop((char *)string);
mutex_unlock(&evloopMutex);
FREE(string); FREE(string);
// #ifdef __MINGW32__ // #ifdef __MINGW32__
// bgtid.p = NULL; // bgtid.p = NULL;
@ -459,11 +453,8 @@ exec_controls(wordlist *newcontrols)
#endif #endif
#else #else
wordlist *wl; wordlist *wl;
for (wl = shcontrols; wl; wl = wl->wl_next) {
mutex_lock(&evloopMutex);
for (wl = shcontrols; wl; wl = wl->wl_next)
cp_evloop(wl->wl_word); cp_evloop(wl->wl_word);
mutex_unlock(&evloopMutex);
}
#endif #endif
} }
@ -571,22 +562,16 @@ runc(char* command)
if (fl_running) { if (fl_running) {
if (fl_exited) { if (fl_exited) {
_thread_stop(); _thread_stop();
mutex_lock(&evloopMutex);
cp_evloop(buf); cp_evloop(buf);
mutex_unlock(&evloopMutex);
} else { } else {
fprintf(stderr, "Warning: cannot execute \"%s\", type \"bg_halt\" first\n", buf); fprintf(stderr, "Warning: cannot execute \"%s\", type \"bg_halt\" first\n", buf);
} }
} else { } else {
/*do the command*/ /*do the command*/
mutex_lock(&evloopMutex);
cp_evloop(buf); cp_evloop(buf);
mutex_unlock(&evloopMutex);
} }
#else #else
mutex_lock(&evloopMutex);
cp_evloop(buf); cp_evloop(buf);
mutex_unlock(&evloopMutex);
#endif /*THREADS*/ #endif /*THREADS*/
signal(SIGINT, oldHandler); signal(SIGINT, oldHandler);
return 0; return 0;
@ -730,19 +715,16 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi
pthread_mutex_init(&triggerMutex, NULL); pthread_mutex_init(&triggerMutex, NULL);
pthread_mutex_init(&allocMutex, NULL); pthread_mutex_init(&allocMutex, NULL);
pthread_mutex_init(&fputsMutex, NULL); pthread_mutex_init(&fputsMutex, NULL);
pthread_mutex_init(&evloopMutex, NULL);
cont_condition = FALSE; cont_condition = FALSE;
#else #else
#ifdef SRW #ifdef SRW
InitializeSRWLock(&triggerMutex); InitializeSRWLock(&triggerMutex);
InitializeSRWLock(&allocMutex); InitializeSRWLock(&allocMutex);
InitializeSRWLock(&fputsMutex); InitializeSRWLock(&fputsMutex);
InitializeSRWLock(&evloopMutex);
#else #else
InitializeCriticalSection(&triggerMutex); InitializeCriticalSection(&triggerMutex);
InitializeCriticalSection(&allocMutex); InitializeCriticalSection(&allocMutex);
InitializeCriticalSection(&fputsMutex); InitializeCriticalSection(&fputsMutex);
InitializeCriticalSection(&evloopMutex);
#endif #endif
#endif #endif
// Id of primary thread // Id of primary thread

Loading…
Cancel
Save