root/alarm.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dmtcp_Alarm_EventHook

   1 /* FILE: alarm.cpp
   2  * AUTHOR: Rohan Garg
   3  * EMAIL: rohgarg@ccs.neu.edu
   4  * Copyright (C) 2015 Rohan Garg
   5  *
   6  * This program is free software: you can redistribute it and/or modify
   7  * it under the terms of the GNU Lesser General Public License as published by
   8  * the Free Software Foundation, either version 3 of the License, or
   9  * (at your option) any later version.
  10  *
  11  * This program is distributed in the hope that it will be useful,
  12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  * GNU Lesser General Public License for more details.
  15  *
  16  * You should have received a copy of the GNU Lesser General Public License
  17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18  */
  19 
  20 #include <stdlib.h>
  21 #include <unistd.h>
  22 #include <stdio.h>
  23 
  24 #include "dmtcp.h"
  25 
  26 #include "jassert.h"
  27 
  28 void
  29 dmtcp_Alarm_EventHook(DmtcpEvent_t event, DmtcpEventData_t *data)
  30 {
  31   static unsigned int timeLeft = 0;
  32   switch (event) {
  33     case DMTCP_EVENT_WRITE_CKPT:
  34       {
  35         timeLeft = alarm(0);
  36         JTRACE("*** Alarm stopped. ***") (timeLeft);
  37         break;
  38       }
  39     case DMTCP_EVENT_THREADS_RESUME:
  40       {
  41         /* Need to restart the timer on resume/restart. */
  42         if (timeLeft > 0) {
  43           JTRACE("*** Resuming alarm. ***") (timeLeft);
  44           timeLeft = alarm(timeLeft);
  45         }
  46         break;
  47       }
  48     default:
  49       break;
  50   }
  51 }

/* [<][>][^][v][top][bottom][index][help] */