From 896c9305834476c2243385ec2be7ba1bbf436065 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 13 Jul 2012 10:22:30 +0200 Subject: partial_sim: Don't start too many calculations by accident --- src/partial_sim.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/partial_sim.c') diff --git a/src/partial_sim.c b/src/partial_sim.c index 6b99864e..2a24b8f6 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -191,6 +191,7 @@ struct queue_args pthread_mutex_t full_lock; int n_done; + int n_started; int n_to_do; SymOpList *sym; @@ -227,11 +228,16 @@ static void *create_job(void *vqargs) struct worker_args *wargs; struct queue_args *qargs = vqargs; + /* All done already? */ + if ( qargs->n_started == qargs->n_to_do ) return NULL; + wargs = malloc(sizeof(struct worker_args)); wargs->qargs = qargs; wargs->image = *qargs->template_image; + qargs->n_started++; + return wargs; } @@ -514,6 +520,7 @@ int main(int argc, char *argv[]) pthread_mutex_init(&qargs.full_lock, NULL); qargs.n_to_do = n; qargs.n_done = 0; + qargs.n_started = 0; qargs.sym = sym; qargs.random_intensities = random_intensities; qargs.cell = cell; -- cgit v1.2.3