diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-09-23 15:47:50 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-09-23 15:48:04 -0700 |
commit | 2deb1197bc57bf732a900671e653073b37d67398 (patch) | |
tree | 99e9dceb40e5cc601883ce826537c2cb0dd300c2 | |
parent | 0cada7f60d7897e6afb2d63fd00cf2e7703967b8 (diff) | |
download | riscv-isa-sim-2deb1197bc57bf732a900671e653073b37d67398.zip riscv-isa-sim-2deb1197bc57bf732a900671e653073b37d67398.tar.gz riscv-isa-sim-2deb1197bc57bf732a900671e653073b37d67398.tar.bz2 |
Fix Scott's deadlock
Not Scott's fault, I mean
-rw-r--r-- | riscv/htif.cc | 7 | ||||
-rw-r--r-- | riscv/htif.h | 4 | ||||
-rw-r--r-- | riscv/sim.cc | 7 |
3 files changed, 11 insertions, 7 deletions
diff --git a/riscv/htif.cc b/riscv/htif.cc index 679ef93..d7b9f63 100644 --- a/riscv/htif.cc +++ b/riscv/htif.cc @@ -15,9 +15,14 @@ htif_isasim_t::htif_isasim_t(sim_t* _sim, const std::vector<std::string>& args) { } -void htif_isasim_t::tick() +bool htif_isasim_t::tick() { + if (done()) + return false; + do tick_once(); while (reset); + + return true; } void htif_isasim_t::tick_once() diff --git a/riscv/htif.h b/riscv/htif.h index 3e4a88d..2a940ad 100644 --- a/riscv/htif.h +++ b/riscv/htif.h @@ -17,8 +17,7 @@ class htif_isasim_t : public htif_pthread_t { public: htif_isasim_t(sim_t* _sim, const std::vector<std::string>& args); - void tick(); - bool done(); + bool tick(); private: sim_t* sim; @@ -26,6 +25,7 @@ private: uint8_t seqno; void tick_once(); + bool done(); }; #endif diff --git a/riscv/sim.cc b/riscv/sim.cc index 864ec09..a4a1c17 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -74,9 +74,8 @@ reg_t sim_t::get_scr(int which) void sim_t::run() { - while (!htif->done()) + while (htif->tick()) { - htif->tick(); if (debug || ctrlc_pressed) interactive(); else @@ -115,6 +114,6 @@ bool sim_t::running() void sim_t::stop() { procs[0]->state.tohost = 1; - while (!htif->done()) - htif->tick(); + while (htif->tick()) + ; } |