root/threadsync.h

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

INCLUDED FROM


   1 /****************************************************************************
   2  *   Copyright (C) 2006-2012 by Jason Ansel, Kapil Arya, and Gene Cooperman *
   3  *   jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu              *
   4  *                                                                          *
   5  *  This file is part of DMTCP.                                             *
   6  *                                                                          *
   7  *  DMTCP is free software: you can redistribute it and/or                  *
   8  *  modify it under the terms of the GNU Lesser General Public License as   *
   9  *  published by the Free Software Foundation, either version 3 of the      *
  10  *  License, or (at your option) any later version.                         *
  11  *                                                                          *
  12  *  DMTCP is distributed in the hope that it will be useful,                *
  13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
  15  *  GNU Lesser General Public License for more details.                     *
  16  *                                                                          *
  17  *  You should have received a copy of the GNU Lesser General Public        *
  18  *  License along with DMTCP:dmtcp/src.  If not, see                        *
  19  *  <http://www.gnu.org/licenses/>.                                         *
  20  ****************************************************************************/
  21 
  22 #ifndef THREADSYNC_H
  23 #define THREADSYNC_H
  24 
  25 
  26 #define WRAPPER_EXECUTION_DISABLE_CKPT()                \
  27   /*JTRACE("Acquiring wrapperExecutionLock");*/         \
  28   bool __wrapperExecutionLockAcquired =                 \
  29     dmtcp::ThreadSync::wrapperExecutionLockLock();      \
  30   if (__wrapperExecutionLockAcquired) {                 \
  31     /*JTRACE("Acquired wrapperExecutionLock"); */       \
  32   }
  33 
  34 #define WRAPPER_EXECUTION_ENABLE_CKPT()                 \
  35   if (__wrapperExecutionLockAcquired) {                 \
  36     /*JTRACE("Releasing wrapperExecutionLock"); */      \
  37     dmtcp::ThreadSync::wrapperExecutionLockUnlock();    \
  38   }
  39 
  40 #define DUMMY_WRAPPER_EXECUTION_DISABLE_CKPT()          \
  41   bool __wrapperExecutionLockAcquired = false;
  42 
  43 #define WRAPPER_EXECUTION_GET_EXCL_LOCK()               \
  44   bool __wrapperExecutionLockAcquired                   \
  45     = dmtcp::ThreadSync::wrapperExecutionLockLockExcl();\
  46   dmtcp::ThreadSync::unsetOkToGrabLock();
  47 
  48 #define WRAPPER_EXECUTION_RELEASE_EXCL_LOCK()           \
  49   WRAPPER_EXECUTION_ENABLE_CKPT();                      \
  50   dmtcp::ThreadSync::setOkToGrabLock();
  51 
  52 namespace dmtcp
  53 {
  54   namespace ThreadSync
  55   {
  56     void acquireLocks();
  57     void releaseLocks();
  58     void resetLocks();
  59     void initThread();
  60     void initMotherOfAll();
  61 
  62     void destroyDmtcpWorkerLockLock();
  63     void destroyDmtcpWorkerLockUnlock();
  64     int destroyDmtcpWorkerLockTryLock();
  65 
  66     void delayCheckpointsLock();
  67     void delayCheckpointsUnlock();
  68 
  69     bool wrapperExecutionLockLock();
  70     void wrapperExecutionLockUnlock();
  71     bool wrapperExecutionLockLockExcl();
  72 
  73     bool threadCreationLockLock();
  74     void threadCreationLockUnlock();
  75 
  76     bool libdlLockLock();
  77     void libdlLockUnlock();
  78     void waitForThreadsToFinishInitialization();
  79     void incrementUninitializedThreadCount();
  80     void decrementUninitializedThreadCount();
  81     void threadFinishedInitialization();
  82 
  83     void disableLockAcquisitionForThisThread();
  84     void enableLockAcquisitionForThisThread();
  85 
  86     bool isThisThreadHoldingAnyLocks();
  87     bool sendCkptSignalOnUnlock();
  88 
  89     bool isOkToGrabLock();
  90     void setOkToGrabLock();
  91     void unsetOkToGrabLock();
  92 
  93     void sendCkptSignalOnFinalUnlock();
  94     void setSendCkptSignalOnFinalUnlock();
  95 
  96 #if TRACK_DLOPEN_DLSYM_FOR_LOCKS
  97     bool isThreadPerformingDlopenDlsym();
  98     void setThreadPerformingDlopenDlsym();
  99     void unsetThreadPerformingDlopenDlsym();
 100 #endif
 101 
 102     void incrNumUserThreads();
 103     void processPreResumeCB();
 104     void waitForUserThreadsToFinishPreResumeCB();
 105   };
 106 }
 107 
 108 #endif

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