Skip to content
Snippets Groups Projects
Commit dc99b5bf authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Use careful locks and unlocks around the activation of the gravity drifts.

parent 88c04547
Branches
Tags
1 merge request!576Gravity splittask (non-MPI)
...@@ -1435,16 +1435,24 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { ...@@ -1435,16 +1435,24 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) {
/* Set the do_grav_sub_drifts all the way up and activate the super drift /* Set the do_grav_sub_drifts all the way up and activate the super drift
if this has not yet been done. */ if this has not yet been done. */
if (c == c->super_gravity) { if (c == c->super_gravity) {
/* Lock the cell and actuivate things */
if(lock_lock(&c->lock) != 0) error("Error trying to lock cell");
if(c->drift_gpart == NULL) error("Trying to activate un-existing c->drift_gpart"); if(c->drift_gpart == NULL) error("Trying to activate un-existing c->drift_gpart");
scheduler_activate(s, c->drift_gpart); if(c->drift_gpart != NULL) scheduler_activate(s, c->drift_gpart);
if(lock_unlock(&c->lock) != 0) error("Error trying to unlock cell");
} else { } else {
for (struct cell *parent = c->parent; for (struct cell *parent = c->parent;
parent != NULL && !parent->do_grav_sub_drift; parent != NULL && !parent->do_grav_sub_drift;
parent = parent->parent) { parent = parent->parent) {
parent->do_grav_sub_drift = 1; parent->do_grav_sub_drift = 1;
if (parent == c->super_gravity) { if (parent == c->super_gravity) {
/* Lock the cell and actuivate things */
if(lock_lock(&parent->lock) != 0) error("Error trying to lock parent cell");
if(parent->drift_gpart == NULL) error("Trying to activate un-existing parent->drift_gpart"); if(parent->drift_gpart == NULL) error("Trying to activate un-existing parent->drift_gpart");
scheduler_activate(s, parent->drift_gpart); if(parent->drift_gpart != NULL)scheduler_activate(s, parent->drift_gpart);
if(lock_unlock(&parent->lock) != 0) error("Error trying to unlock parent cell");
break; break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment