aboutsummaryrefslogtreecommitdiff
path: root/src/indexamajig.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-04-01 17:53:04 +0200
committerThomas White <taw@physics.org>2010-04-01 17:53:04 +0200
commit9cd40c762e1db936f14f61da26b7fad17cbd989c (patch)
treee7168197aeecc1f0732a550a239f812411aef859 /src/indexamajig.c
parentc19cd3d161b88e5ea487b2660d81b53ace2645a2 (diff)
indexamajig: Protect GPU context with mutex
Diffstat (limited to 'src/indexamajig.c')
-rw-r--r--src/indexamajig.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index e2ca63d4..ad6fc441 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -43,7 +43,8 @@
struct process_args
{
char *filename;
- pthread_mutex_t *output_mutex;
+ pthread_mutex_t *output_mutex; /* Protects stdout */
+ pthread_mutex_t *gpu_mutex; /* Protects "gctx" */
UnitCell *cell;
int config_cmfilter;
int config_noisefilter;
@@ -315,8 +316,10 @@ static void *process_image(void *pargsv)
/* Simulate if requested */
if ( config_simulate ) {
if ( config_gpu ) {
+ pthread_mutex_lock(pargs->gpu_mutex);
simulate_and_write(simage, &gctx, intensities,
counts, cell);
+ pthread_mutex_unlock(pargs->gpu_mutex);
} else {
simulate_and_write(simage, NULL, intensities,
counts, cell);
@@ -381,6 +384,7 @@ int main(int argc, char *argv[])
int worker_active[MAX_THREADS];
int i;
pthread_mutex_t output_mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_t gpu_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Long options */
const struct option longopts[] = {
@@ -536,6 +540,7 @@ int main(int argc, char *argv[])
pargs = malloc(sizeof(*pargs));
pargs->filename = prefixed;
pargs->output_mutex = &output_mutex;
+ pargs->gpu_mutex = &gpu_mutex;
pargs->config_cmfilter = config_cmfilter;
pargs->config_noisefilter = config_noisefilter;
pargs->config_writedrx = config_writedrx;