summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael LeBeane <michael.lebeane@amd.com>2018-04-27 19:49:26 -0400
committerAnthony Gutierrez <anthony.gutierrez@amd.com>2018-05-30 19:46:09 +0000
commit51f43598154fc744375558bccdb271d9961bb614 (patch)
treeb868a683584fd87d98a0a9a1a6b383745f9483e7
parent8100fb5f19b09a93c1f3e3e8533322e1fa73e6d3 (diff)
downloadgem5-51f43598154fc744375558bccdb271d9961bb614.tar.xz
dev: Exit correctly in dist-gem5 for SE mode
Do not allow the exit() syscall to terminate gem5 when running in dist-gem5 mode. The exit must be coordinated by the distributed interface instead. Change-Id: I57f47610b59fe9e18ba3a1667fb5e45cecac1a81 Reviewed-on: https://gem5-review.googlesource.com/10461 Maintainer: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Mohammad Alian <m.alian1369@gmail.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
-rw-r--r--src/sim/syscall_emul.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 8736176ed..7f4d76630 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -43,6 +43,7 @@
#include "base/trace.hh"
#include "config/the_isa.hh"
#include "cpu/thread_context.hh"
+#include "dev/net/dist_iface.hh"
#include "mem/page_table.hh"
#include "sim/process.hh"
#include "sim/sim_exit.hh"
@@ -102,6 +103,20 @@ exitImpl(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
for (auto &system: sys->systemList)
activeContexts += system->numRunningContexts();
if (activeContexts == 1) {
+ /**
+ * Even though we are terminating the final thread context, dist-gem5
+ * requires the simulation to remain active and provide
+ * synchronization messages to the switch process. So we just halt
+ * the last thread context and return. The simulation will be
+ * terminated by dist-gem5 in a coordinated manner once all nodes
+ * have signaled their readiness to exit. For non dist-gem5
+ * simulations, readyToExit() always returns true.
+ */
+ if (!DistIface::readyToExit(0)) {
+ tc->halt();
+ return status;
+ }
+
exitSimLoop("exiting with last active thread context", status & 0xff);
return status;
}