summaryrefslogtreecommitdiff
path: root/src/sim/process.hh
diff options
context:
space:
mode:
authorRick Strong <rstrong@cs.ucsd.edu>2007-11-29 00:22:46 -0500
committerRick Strong <rstrong@cs.ucsd.edu>2007-11-29 00:22:46 -0500
commit376c7285eedf5b235a414accf9f5253a4d55633e (patch)
tree1382af9b9573e5948df9720d0c1a2465aca6bd9d /src/sim/process.hh
parentab598eadbfeefceb6501d4cca13147b660642d9e (diff)
downloadgem5-376c7285eedf5b235a414accf9f5253a4d55633e.tar.xz
Serialization: Fix serialization of file descriptors. Make sure open
file descriptors are reopened and the file pointer is in the same place as when the checkpoint occured. Signed-off by: Ali Saidi --HG-- extra : convert_revision : d9d2cd388c9c02f60e1269d6845891c35f94fc47
Diffstat (limited to 'src/sim/process.hh')
-rw-r--r--src/sim/process.hh48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/sim/process.hh b/src/sim/process.hh
index 0d2db959c..29d6e5aae 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -144,10 +144,40 @@ class Process : public SimObject
//separated.
uint64_t M5_pid;
+ class FdMap
+ {
+ public:
+ int fd;
+ std::string filename;
+ int mode;
+ int flags;
+ bool isPipe;
+ int readPipeSource;
+ uint64_t fileOffset;
+
+
+ FdMap()
+ {
+ fd = -1;
+ filename = "NULL";
+ mode = 0;
+ flags = 0;
+ isPipe = false;
+ readPipeSource = 0;
+ fileOffset = 0;
+
+ }
+
+ void serialize(std::ostream &os);
+ void unserialize(Checkpoint *cp, const std::string &section);
+
+ };
+
private:
// file descriptor remapping support
- static const int MAX_FD = 256; // max legal fd value
- int fd_map[MAX_FD+1];
+ static const int MAX_FD = 256; // max legal fd value
+ FdMap fd_map[MAX_FD+1];
+
public:
// static helper functions to generate file descriptors for constructor
@@ -168,7 +198,7 @@ class Process : public SimObject
void dup_fd(int sim_fd, int tgt_fd);
// generate new target fd for sim_fd
- int alloc_fd(int sim_fd);
+ int alloc_fd(int sim_fd, std::string filename, int flags, int mode, bool pipe);
// free target fd (e.g., after close)
void free_fd(int tgt_fd);
@@ -176,6 +206,18 @@ class Process : public SimObject
// look up simulator fd for given target fd
int sim_fd(int tgt_fd);
+ // look up simulator fd_map object for a given target fd
+ FdMap * sim_fd_obj(int tgt_fd);
+
+ // fix all offsets for currently open files and save them
+ void fix_file_offsets();
+
+ // find all offsets for currently open files and save them
+ void find_file_offsets();
+
+ // set the source of this read pipe for a checkpoint resume
+ void setReadPipeSource(int read_pipe_fd, int source_fd);
+
virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
// check if the this addr is on the next available page and allocate it