Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
static void
checkpoint_thread_loop(void *data)
{
  uint8_t cmd;
  int fd;

  while(1) {
    /* Store command and file descriptor on stack */
    cmd = preset_cmd;
    fd = preset_fd;

    /* Handle command */
    if(cmd == COMMAND_ROLLBACK) {
      PRINTF_COMMAND("RB:START\n");
      thread_rollback(fd);
      nr_rollbacks++;
      PRINTF_COMMAND("RB:DONE %u\n", nr_rollbacks);
      /* TODO Synch before leaving this thread. */
    } else if(cmd == COMMAND_CHECKPOINT) {
      PRINTF_COMMAND("CP:START\n");
      thread_checkpoint(fd);
      thread_metrics();
      nr_checkpoints++;
      PRINTF_COMMAND("CP:DONE %u\n", nr_checkpoints);
    } else if(cmd == COMMAND_METRICS) {
      thread_metrics();
    } else {
      printf("ERROR: Unknown thread command: %u\n", cmd);
    }

    /* Return to Contiki */
    mt_yield();
  }
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
static void
thread_loop(void *data)
{
  uint8_t cmd;
  int fd;

  while(1) {
    /* Store command and file descriptor on stack */
    cmd = preset_cmd;
    fd = preset_fd;

    /* Handle command */
    if(cmd == COMMAND_ROLLBACK) {
      PRINTF("Rolling back");
      thread_rollback(fd);
      PRINTF(" done!\n");
    } else if(cmd == COMMAND_CHECKPOINT) {
      PRINTF("Checkpointing");
      thread_checkpoint(fd);
      PRINTF(" done!\n");
    } else if(cmd == COMMAND_TBR) {
      PRINTF("Writing TBR");
     // write_word(fd, TBR);
      PRINTF(" done!\n");
    } else {
      printf("Error: unknown command: %u\n", cmd);
    }

    /* Return to main Contiki thread */
    mt_yield();
  }
}