From 4410876773fa076a2b197cfbaf23ceea73137397 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 10 Nov 2005 21:08:33 -0500 Subject: Actually free Process fd_map entries when a file is closed... amazingly we never did that before. Caused us to run out of file descriptors in twolf. sim/process.cc: Add free_fd() method to free closed target fd in simulator fd map. Rename open_fd() to alloc_fd() for symmetry with free_fd(). sim/process.hh: Add free_fd() method to free closed target fd in simulator fd map. Rename open_fd() to alloc_fd() for symmetry with free_fd(). Crank up MAX_FD while we're at it. sim/syscall_emul.cc: Call free_fd() on process when target closes a file. sim/syscall_emul.hh: Process open_fd() renamed to alloc_fd(). --HG-- extra : convert_revision : d780f4ccfd5a0989230b0afbdbd276212b87550c --- sim/process.hh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sim/process.hh') diff --git a/sim/process.hh b/sim/process.hh index 28c16a444..2116ef632 100644 --- a/sim/process.hh +++ b/sim/process.hh @@ -124,7 +124,7 @@ class Process : public SimObject private: // file descriptor remapping support - static const int MAX_FD = 100; // max legal fd value + static const int MAX_FD = 256; // max legal fd value int fd_map[MAX_FD+1]; public: @@ -146,7 +146,10 @@ class Process : public SimObject void dup_fd(int sim_fd, int tgt_fd); // generate new target fd for sim_fd - int open_fd(int sim_fd); + int alloc_fd(int sim_fd); + + // free target fd (e.g., after close) + void free_fd(int tgt_fd); // look up simulator fd for given target fd int sim_fd(int tgt_fd); -- cgit v1.2.3