diff options
author | Thomas White <taw@physics.org> | 2012-07-13 10:22:30 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-07-13 10:22:30 +0200 |
commit | 896c9305834476c2243385ec2be7ba1bbf436065 (patch) | |
tree | beae808b993c29ad88b86cf50306d29b4f6a0f60 | |
parent | bb0cd5c3603f815183e03d5e2dad76c51c449864 (diff) |
partial_sim: Don't start too many calculations by accident
-rw-r--r-- | src/partial_sim.c | 7 |
1 files changed, 7 insertions, 0 deletions
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; |