locking and iterating through queues is expensive so added flag that indicates if there is any interrupt pending

This commit is contained in:
folkert van heusden 2023-03-27 09:26:10 +02:00
parent 4bdc5272b2
commit 2563bbac57
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 8 additions and 3 deletions

10
cpu.cpp
View file

@ -278,7 +278,9 @@ bool cpu::check_queued_interrupts()
return true;
}
}
any_queued_interrupts = false;
return false;
}
@ -292,6 +294,8 @@ void cpu::queue_interrupt(const uint8_t level, const uint8_t vector)
qi_cv.notify_all();
any_queued_interrupts = true;
DOLOG(debug, true, "Queueing interrupt vector %o (IPL %d, current: %d), n: %zu", vector, level, getPSW_spl(), it->second.size());
}
@ -2159,8 +2163,8 @@ void cpu::step_a()
if ((b->getMMR0() & 0160000) == 0)
b->clearMMR1();
if (check_queued_interrupts())
return;
if (any_queued_interrupts && check_queued_interrupts())
return; // documentation
}
void cpu::step_b()

1
cpu.h
View file

@ -43,6 +43,7 @@ private:
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
std::mutex qi_lock;
std::condition_variable qi_cv;
std::atomic_bool any_queued_interrupts { false };
std::set<uint16_t> breakpoints;