1 /****************************************************************************
2 * Copyright (C) 2006-2008 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 the dmtcp/src module of DMTCP (DMTCP:dmtcp/src). *
6 * *
7 * DMTCP:dmtcp/src 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:dmtcp/src 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 #include "dmtcpalloc.h"
23 #include <sys/types.h>
24 #include <unistd.h>
25 #include <sys/time.h>
26 #include <time.h>
27 #include <iostream>
28 #include "constants.h"
29 #include "../jalib/jserialize.h"
30
31 #ifndef UNIQUEPID_H
32 #define UNIQUEPID_H
33
34 namespace dmtcp
35 {
36
37 struct UniquePid
38 {
39 public:
40 static dmtcp::UniquePid& ParentProcess();
41 static dmtcp::UniquePid& ThisProcess(bool disableJTrace = false);
42 UniquePid();
43 UniquePid(pid_t pid);
44 UniquePid ( long host, pid_t pd, time_t tm )
45 : _pid ( pd ), _hostid ( host ), _time ( tm ), _generation ( 0 ) {}
46 UniquePid ( long host, pid_t pd, time_t tm, int gen )
47 : _pid ( pd ), _hostid ( host ), _time ( tm ), _generation ( gen) {}
48
49 long hostid() const;
50 pid_t pid() const;
51 time_t time() const;
52 int generation() const;
53 void incrementGeneration();
54 static const char* checkpointFilename();
55 static dmtcp::string checkpointFilesDirName();
56 static dmtcp::string dmtcpTableFilename();
57 #ifdef PID_VIRTUALIZATION
58 static dmtcp::string pidTableFilename();
59 #endif
60 static const char* ptsSymlinkFilename ( char *pts );
61 static void setTmpDir(const char * envVarTmpDir);
62 static dmtcp::string getTmpDir();
63
64 static void serialize( jalib::JBinarySerializer& o );
65
66 bool operator< ( const UniquePid& that ) const;
67 bool operator== ( const UniquePid& that ) const;
68 bool operator!= ( const UniquePid& that ) const { return ! operator== ( that ); }
69
70 static void resetOnFork ( const dmtcp::UniquePid& newId );
71
72 dmtcp::string toString() const;
73
74 bool isNull() const;
75
76 private:
77 pid_t _pid; //getpid()
78 long _hostid; //gethostid()
79 time_t _time; //time()
|
Event member_decl: |
Class member declaration for _generation. |
| Also see events: |
[uninit_member] |
80 int _generation; //generation()
81 };
82 }
83
84 //to make older versions of gcc work
85 namespace dmtcp
86 {
87 dmtcp::ostream& operator << ( dmtcp::ostream& o,const dmtcp::UniquePid& id );
88 }
89
90 #endif