1
1

* clean up George's threading changes -- we can't check for PROGRESS_THREADS,

as we can have multiple threads in the event library if there are multiple
  MPI threads.  Well, we could, once I fix the need for the lock in
  opal_progress(), which should happen shortly.  Anyway, we need to use the
  same locking scheme throughout the code, and the device support was
  already using the OPAL_THREAD__{lock,unlock} macros, which only go
  active when we think there are multiple threads we care about.

  Also, stop duplicating the OPAL_THREAD_SCOPED_LOCK macro's functionality
  and use it in a bunch of places in the code.

This commit was SVN r11383.
Этот коммит содержится в:
Brian Barrett 2006-08-23 22:19:31 +00:00
родитель 9d5ba9daee
Коммит a9c2b38877
2 изменённых файлов: 10 добавлений и 44 удалений
opal/event

@ -257,8 +257,6 @@ opal_event_init(void)
/* allocate a single active event queue */
opal_event_base_priority_init(current_base, 1);
#if OMPI_ENABLE_PROGRESS_THREADS
#endif
opal_event_enable();
#endif /* HAVE_WORKING_EVENTOPS */
@ -461,13 +459,9 @@ opal_event_process_active(struct event_base *base)
while (ncalls) {
ncalls--;
ev->ev_ncalls = ncalls;
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_unlock(&opal_event_lock);
OPAL_THREAD_UNLOCK(&opal_event_lock);
(*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
opal_mutex_lock(&opal_event_lock);
#else
(*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_LOCK(&opal_event_lock);
}
}
#endif
@ -534,9 +528,7 @@ opal_event_base_loop(struct event_base *base, int flags)
return(0);
#if OPAL_HAVE_WORKING_EVENTOPS
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_lock(&opal_event_lock);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_LOCK(&opal_event_lock);
done = 0;
while (!done && opal_event_enabled) {
@ -557,9 +549,7 @@ opal_event_base_loop(struct event_base *base, int flags)
res = (*event_sigcb)();
if (res == -1) {
errno = EINTR;
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_unlock(&opal_event_lock);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_UNLOCK(&opal_event_lock);
return (-1);
}
}
@ -583,9 +573,7 @@ opal_event_base_loop(struct event_base *base, int flags)
/* If we have no events, we just exit */
if (!opal_event_haveevents(base)) {
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_unlock(&opal_event_lock);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_UNLOCK(&opal_event_lock);
event_debug(("%s: no events registered.", __func__));
return (1);
}
@ -600,9 +588,7 @@ opal_event_base_loop(struct event_base *base, int flags)
if (res == -1) {
opal_output(0, "opal_event_loop: ompi_evesel->dispatch() failed.");
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_unlock(&opal_event_lock);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_UNLOCK(&opal_event_lock);
return (-1);
}
@ -618,9 +604,7 @@ opal_event_base_loop(struct event_base *base, int flags)
event_debug(("%s: asked to terminate loop.", __func__));
#if OMPI_ENABLE_PROGRESS_THREADS
opal_mutex_unlock(&opal_event_lock);
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
OPAL_THREAD_UNLOCK(&opal_event_lock);
return (base->event_count_active);
#else
return 0;

@ -232,13 +232,7 @@ opal_event_add(struct opal_event *ev, struct timeval *tv)
{
extern opal_mutex_t opal_event_lock;
int rc;
if(opal_using_threads()) {
opal_mutex_lock(&opal_event_lock);
rc = opal_event_add_i(ev, tv);
opal_mutex_unlock(&opal_event_lock);
} else {
rc = opal_event_add_i(ev, tv);
}
OPAL_THREAD_SCOPED_LOCK(&opal_event_lock, rc = opal_event_add_i(ev, tv));
return rc;
}
@ -247,26 +241,14 @@ opal_event_del(struct opal_event *ev)
{
extern opal_mutex_t opal_event_lock;
int rc;
if(opal_using_threads()) {
opal_mutex_lock(&opal_event_lock);
rc = opal_event_del_i(ev);
opal_mutex_unlock(&opal_event_lock);
} else {
rc = opal_event_del_i(ev);
}
OPAL_THREAD_SCOPED_LOCK(&opal_event_lock, rc = opal_event_del_i(ev));
return rc;
}
static inline void
opal_event_active(struct opal_event* ev, int res, short ncalls)
{
if(opal_using_threads()) {
opal_mutex_lock(&opal_event_lock);
opal_event_active_i(ev, res, ncalls);
opal_mutex_unlock(&opal_event_lock);
} else {
opal_event_active_i(ev, res, ncalls);
}
OPAL_THREAD_SCOPED_LOCK(&opal_event_lock, opal_event_active_i(ev, res, ncalls));
}
static inline int