Skip to content

Commit c91cb67

Browse files
committed
fix a bug in the unnamed semaphore section that was introduced when I tried to unify the named and unnamed semaphore logic.
1 parent 57c301f commit c91cb67

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

ompi/mca/sharedfp/sm/sharedfp_sm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ int mca_sharedfp_sm_iwrite (mca_io_ompio_file_t *fh,
100100
/*--------------------------------------------------------------*
101101
*Structures and definitions only for this component
102102
*--------------------------------------------------------------*/
103-
103+
#define OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES 1
104104
struct sm_offset{
105-
sem_t *mutex; /* the mutex: a Posix memory-based unnamed semaphore */
105+
sem_t mutex; /* the mutex: a Posix memory-based unnamed semaphore */
106106
long long offset; /* and the shared file pointer offset */
107107
};
108108

ompi/mca/sharedfp/sm/sharedfp_sm_file_open.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
185185
MPI_Offset position=0;
186186

187187
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
188-
sem_wait(sm_offset_ptr->mutex);
188+
sem_wait(&sm_offset_ptr->mutex);
189189
sm_offset_ptr->offset=position;
190-
sem_post(sm_offset_ptr->mutex);
190+
sem_post(&sm_offset_ptr->mutex);
191191
#else
192192
sem_wait(sm_data->mutex);
193193
sm_offset_ptr->offset=position;
@@ -236,7 +236,7 @@ int mca_sharedfp_sm_file_close (mca_io_ompio_file_t *fh)
236236
if (file_data->sm_offset_ptr) {
237237
/* destroy semaphore */
238238
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
239-
sem_destroy(file_data->sm_offset_ptr->mutex);
239+
sem_destroy(&file_data->sm_offset_ptr->mutex);
240240
#else
241241
sem_unlink (file_data->sem_name);
242242
free (file_data->sem_name);

ompi/mca/sharedfp/sm/sharedfp_sm_request_position.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
4949
/* Aquire an exclusive lock */
5050

5151
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
52-
sem_wait(sm_offset_ptr->mutex);
52+
sem_wait(&sm_offset_ptr->mutex);
5353
#else
5454
sem_wait(sm_data->mutex);
5555
#endif
@@ -75,7 +75,7 @@ int mca_sharedfp_sm_request_position(struct mca_sharedfp_base_data_t * sh,
7575
}
7676

7777
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
78-
sem_post(sm_offset_ptr->mutex);
78+
sem_post(&sm_offset_ptr->mutex);
7979
#else
8080
sem_post(sm_data->mutex);
8181
#endif

ompi/mca/sharedfp/sm/sharedfp_sm_seek.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
122122
sm_offset_ptr = sm_data->sm_offset_ptr;
123123

124124
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
125-
sem_wait(sm_offset_ptr->mutex);
125+
sem_wait(&sm_offset_ptr->mutex);
126126
#else
127127
sem_wait(sm_data->mutex);
128128
#endif
@@ -135,7 +135,7 @@ mca_sharedfp_sm_seek (mca_io_ompio_file_t *fh,
135135
printf("sharedfp_sm_seek: Releasing sm lock...rank=%d",rank); fflush(stdout);
136136
}
137137
#ifdef OMPIO_SHAREDFP_USE_UNNAMED_SEMAPHORES
138-
sem_post(sm_offset_ptr->mutex);
138+
sem_post(&sm_offset_ptr->mutex);
139139
#else
140140
sem_post(sm_data->mutex);
141141
#endif

0 commit comments

Comments
 (0)