1
1

use seperate thread rather than event handler

This commit was SVN r3745.
Этот коммит содержится в:
Tim Woodall 2004-12-07 23:43:24 +00:00
родитель 538e4cb510
Коммит be7ac2233b
2 изменённых файлов: 13 добавлений и 19 удалений

Просмотреть файл

@ -125,7 +125,7 @@ struct mca_ptl_sm_component_t {
#if OMPI_HAVE_THREADS == 1 #if OMPI_HAVE_THREADS == 1
char sm_fifo_path[PATH_MAX]; /**< path to fifo used to signal this process */ char sm_fifo_path[PATH_MAX]; /**< path to fifo used to signal this process */
int sm_fifo_fd; /**< file descriptor corresponding to opened fifo */ int sm_fifo_fd; /**< file descriptor corresponding to opened fifo */
ompi_event_t sm_fifo_event; /**< event for callbacks on fifo activity */ ompi_thread_t sm_fifo_thread;
#endif #endif
}; };
typedef struct mca_ptl_sm_component_t mca_ptl_sm_component_t; typedef struct mca_ptl_sm_component_t mca_ptl_sm_component_t;
@ -418,7 +418,7 @@ typedef struct mca_ptl_sm_exchange{
}mca_ptl_sm_exchange_t; }mca_ptl_sm_exchange_t;
#if OMPI_HAVE_THREADS == 1 #if OMPI_HAVE_THREADS == 1
void mca_ptl_sm_component_event_handler(int sd, short flags, void* user); void mca_ptl_sm_component_event_thread(ompi_object_t*);
#endif #endif
#if OMPI_HAVE_THREADS == 1 #if OMPI_HAVE_THREADS == 1

Просмотреть файл

@ -211,9 +211,9 @@ int mca_ptl_sm_component_close(void)
#if OMPI_HAVE_THREADS == 1 #if OMPI_HAVE_THREADS == 1
/* close/cleanup fifo create for event notification */ /* close/cleanup fifo create for event notification */
if(mca_ptl_sm_component.sm_fifo_fd >= 0) { if(mca_ptl_sm_component.sm_fifo_fd >= 0) {
ompi_event_del(&mca_ptl_sm_component.sm_fifo_event);
close(mca_ptl_sm_component.sm_fifo_fd); close(mca_ptl_sm_component.sm_fifo_fd);
unlink(mca_ptl_sm_component.sm_fifo_path); unlink(mca_ptl_sm_component.sm_fifo_path);
ompi_thread_join(&mca_ptl_sm_component.sm_fifo_thread, NULL);
} }
#endif #endif
@ -266,13 +266,9 @@ mca_ptl_base_module_t** mca_ptl_sm_component_init(
return NULL; return NULL;
} }
memset(&mca_ptl_sm_component.sm_fifo_event, 0, sizeof(ompi_event_t)); OBJ_CONSTRUCT(&mca_ptl_sm_component.sm_fifo_thread, ompi_thread_t);
ompi_event_set(&mca_ptl_sm_component.sm_fifo_event, mca_ptl_sm_component.sm_fifo_thread.t_run = mca_ptl_sm_component_event_thread;
mca_ptl_sm_component.sm_fifo_fd, ompi_thread_start(&mca_ptl_sm_component.sm_fifo_thread);
OMPI_EV_READ|OMPI_EV_PERSIST,
mca_ptl_sm_component_event_handler,
NULL);
ompi_event_add(&mca_ptl_sm_component.sm_fifo_event, NULL);
#endif #endif
/* allocate the Shared Memory PTL */ /* allocate the Shared Memory PTL */
@ -332,15 +328,14 @@ int mca_ptl_sm_component_control(int param, void* value, size_t size)
*/ */
#if OMPI_HAVE_THREADS == 1 #if OMPI_HAVE_THREADS == 1
void mca_ptl_sm_component_event_handler(int sd, short flags, void* user) void mca_ptl_sm_component_event_thread(ompi_object_t* thread)
{ {
unsigned char cmd; while(1) {
int rc; unsigned char cmd;
mca_ptl_sm_component_progress(0); if(read(mca_ptl_sm_component.sm_fifo_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) {
if(read(sd, &cmd, sizeof(cmd)) != sizeof(cmd)) { return;
ompi_output(0, "mca_ptl_sm_component_event_handler: read failed, errno=%d\n", }
errno); mca_ptl_sm_component_progress(0);
ompi_event_del(&mca_ptl_sm_component.sm_fifo_event);
} }
} }
#endif #endif
@ -631,7 +626,6 @@ int mca_ptl_sm_component_progress(mca_ptl_tstamp_t tstamp)
OMPI_THREAD_UNLOCK(&(mca_ptl_sm_component.sm_pending_ack_lock)); OMPI_THREAD_UNLOCK(&(mca_ptl_sm_component.sm_pending_ack_lock));
} }
return return_status; return return_status;
} }