Example #1
0
int main() {
    int dmtcp_enabled = dmtcp_is_enabled();
    if ( ! dmtcp_enabled ) {
      printf("\n *** dmtcp_is_enabled: executable seems to not be running"
             " under dmtcp_launch.\n\n");
    }

    int original_generation;
    if ( dmtcp_enabled ) {
      original_generation = dmtcp_get_generation();
    }


    int retval = dmtcp_checkpoint();
    if (retval == DMTCP_AFTER_CHECKPOINT) {
      // Wait long enough for checkpoint request to be written out.
      while (dmtcp_get_generation() == original_generation) {
        sleep(1);
    }

      printf("*** dmtcp_checkpoint: This program has now invoked a checkpoint.\n"
             "      It will resume its execution next.\n");
    } else if (retval == DMTCP_AFTER_RESTART) {
      printf("*** dmtcp_checkpoint: This program is now restarting.\n");
    } else if (retval == DMTCP_NOT_PRESENT) {
      printf(" *** dmtcp_checkpoint: DMTCP is not running."
             "  Skipping checkpoint.\n");
    }

    printf("\n*** Process done executing.  Successfully exiting.\n");
    if (retval == DMTCP_AFTER_CHECKPOINT) {
        printf("*** Execute ./dmtcp_restart_script.sh to restart.\n");
    }
    return 0;
}
Example #2
0
File: applic.c Project: dmtcp/dmtcp
int
main()
{
  if (!dmtcp_is_enabled()) {
    printf("\n *** dmtcp_is_enabled: executable seems to not be running"
           " under dmtcp_launch.\n");
  }

  int retval = dmtcp_disable_ckpt();
  if (retval == DMTCP_NOT_PRESENT) {
    printf("\n *** dmtcp_disable_ckpt: DMTCP_NOT_PRESENT."
           "  Will exit.\n");
    exit(0);
  }

  // This assumes that DMTCP is present.
  int original_generation = dmtcp_get_generation();

  printf("*** dmtcp_disable_ckpt: Checkpoints are blocked.\n");
  printf("      But a checkpoint was requested every two seconds: '-i 2'\n");
  printf("*** sleep: sleeping 3 seconds.\n\n");
  sleep(3);
  printf("*** dmtcp_enable_ckpt: Will now unblock checkpointing\n"
         "      and write ./dmtcp_restart_script.sh.\n");
  printf("*** Execute ./dmtcp_restart_script.sh to restart from here.\n");
  dmtcp_enable_ckpt();

  // Wait long enough for checkpoint to be written.
  while (dmtcp_get_generation() == original_generation) {
    sleep(1);
  }

  printf("\n*** Process done executing.  Successfully exiting.\n");
  return 0;
}
Example #3
0
int
main(int argc, char *argv[])
{
  if (dmtcp_is_enabled()) {
    printf("DMTCP is present\n");
  } else {
    printf("DMTCP is not present\n");
  }

  FILE *fp = fopen("/tmp/msg", "w");
  int counter = 0;

  while (1) {
    sleep(1);
    fprintf(fp, "Write counter value = %d to file\n", counter);
    fprintf(stdout, "Write counter value = %d to file\n", counter++);
    fflush(fp);

    if (counter == 5) {
      printf("Prior to dmtcp_checkpoint\n");
      int ret  = dmtcp_checkpoint();
      if (ret == DMTCP_NOT_PRESENT) {
        printf("Checkpoint not successful\n");
      } else if (ret == DMTCP_AFTER_CHECKPOINT){
        printf("Checkpoint successful \n");
        exit(0);
      } else if (ret == DMTCP_AFTER_RESTART) {
        printf("After restart \n");
      } else {
        printf("Unknown state... exiting now!\n");
        exit(-1);
      }
      fclose(fp);
      fp = fopen("/tmp/msg", "a");
    }

    if (counter == 10) {
      printf("Exiting now!\n");
      fclose(fp);
      if (truncate("/tmp/msg", 0) < 0) {
         perror("truncate: ");
         exit(-1);
      }
      exit(0);
    }
  }

  return 0;
}
Example #4
0
int main(int argc, char* argv[])
{
  int count = 0;
  int numCheckpoints, numRestarts;
  while (1)
  {
    if(dmtcp_is_enabled()){
      dmtcp_get_local_status(&numCheckpoints, &numRestarts);
      printf("working... %d (status: %d checkpoints / %d restarts)\n",
             ++count, numCheckpoints, numRestarts);
    }else{
      printf("working... %d\n", ++count);
    }

    sleep(1);

    dmtcp_disable_ckpt();
    printf("dmtcp_disable_ckpt();\n");
    sleep(2);
    printf("dmtcp_enable_ckpt();\n");
    dmtcp_enable_ckpt();
  }
  return 0;
}