- pthread_mutex_lock(&state_mutex);
- deficit--; // Rule D: A child finished its work and reported back
- trace("%d: [CONTROL] Got signal from %d (New Deficit: %d)\n",
- id, status.MPI_SOURCE, deficit);
-
- try_resolve_tree(id);
- pthread_mutex_unlock(&state_mutex);
+ if (sig.type == MSG_KILL) {
+ trace("%d: [CONTROL] Received KILL signal. Shutting down.\n", id);
+ break;
+ }
+ else if (sig.type == MSG_ACK) {
+ pthread_mutex_lock(&state_mutex);
+ deficit--; // Rule D: A child finished its work and reported back
+ trace("%d: [CONTROL] Got signal from %d (New Deficit: %d)\n",
+ id, status.MPI_SOURCE, deficit);
+
+ try_resolve_tree(id);
+ pthread_mutex_unlock(&state_mutex);
+ }