1
1
openmpi/orte/test/system/sigusr_trap.c
Ralph Castain 4fff584a68 Commit the orted-failed-to-start code. This correctly causes the system to detect the failure of an orted to start and allows the system to terminate all procs/orteds that *did* start.
The primary change that underlies all this is in the OOB. Specifically, the problem in the code until now has been that the OOB attempts to resolve an address when we call the "send" to an unknown recipient. The OOB would then wait forever if that recipient never actually started (and hence, never reported back its OOB contact info). In the case of an orted that failed to start, we would correctly detect that the orted hadn't started, but then we would attempt to order all orteds (including the one that failed to start) to die. This would cause the OOB to "hang" the system.

Unfortunately, revising how the OOB resolves addresses introduced a number of additional problems. Specifically, and most troublesome, was the fact that comm_spawn involved the immediate transmission of the rendezvous point from parent-to-child after the child was spawned. The current code used the OOB address resolution as a "barrier" - basically, the parent would attempt to send the info to the child, and then "hold" there until the child's contact info had arrived (meaning the child had started) and the send could be completed.

Note that this also caused comm_spawn to "hang" the entire system if the child never started... The app-failed-to-start helped improve that behavior - this code provides additional relief.

With this change, the OOB will return an ADDRESSEE_UNKNOWN error if you attempt to send to a recipient whose contact info isn't already in the OOB's hash tables. To resolve comm_spawn issues, we also now force the cross-sharing of connection info between parent and child jobs during spawn.

Finally, to aid in setting triggers to the right values, we introduce the "arith" API for the GPR. This function allows you to atomically change the value in a registry location (either divide, multiply, add, or subtract) by the provided operand. It is equivalent to first fetching the value using a "get", then modifying it, and then putting the result back into the registry via a "put".

This commit was SVN r14711.
2007-05-21 18:31:28 +00:00

88 строки
1.8 KiB
C

/* -*- C -*-
*
* $HEADER$
*
* A test to trap user signals
*/
#include <stdio.h>
#include <signal.h>
#include "orte/runtime/runtime.h"
void sigusr_handler(int signum)
{
switch (signum) {
case SIGUSR1:
fprintf(stderr, "Trapped SIGUSR1\n");
break;
case SIGUSR2:
fprintf(stderr, "Trapped SIGUSR2\n");
return;
default:
fprintf(stderr, "Undefined signal %d trapped\n", signum);
return;
}
}
void exit_handler(int signum)
{
int rc;
if (ORTE_SUCCESS != (rc = orte_finalize())) {
fprintf(stderr, "couldn't complete finalize - error code %d\n", rc);
exit(1);
}
exit(0);
}
int main(int argc, char* argv[])
{
int rc;
int i;
double pi;
if (signal(SIGUSR1, sigusr_handler) == SIG_IGN) {
fprintf(stderr, "Could not setup signal trap for SIGUSR1\n");
exit(1);
}
if (signal(SIGUSR2, sigusr_handler) == SIG_IGN) {
fprintf(stderr, "Could not setup signal trap for SIGUSR2\n");
exit(1);
}
if (signal(SIGINT, exit_handler) == SIG_IGN) {
fprintf(stderr, "Could not setup signal trap for SIGINT\n");
exit(1);
}
if (signal(SIGHUP, exit_handler) == SIG_IGN) {
fprintf(stderr, "Could not setup signal trap for SIGHUP\n");
exit(1);
}
if (signal(SIGTERM, exit_handler) == SIG_IGN) {
fprintf(stderr, "Could not setup signal trap for SIGTERM\n");
exit(1);
}
if (ORTE_SUCCESS != (rc = orte_init(ORTE_NON_INFRASTRUCTURE, ORTE_NON_BARRIER))) {
fprintf(stderr, "couldn't complete init - error code %d\n", rc);
exit(1);
}
i = 0;
while (1) {
i++;
pi = i / 3.14159256;
if (i > 100) i = 0;
}
return 0;
}