sim: prioritize async events; prevent starvation
If a time quantum event is the only one in the queue, async events (Ctrl-C, I/O, etc.) will never be processed. So process them first.
This commit is contained in:
parent
20111ba917
commit
b89fd57663
1 changed files with 10 additions and 11 deletions
|
@ -192,37 +192,36 @@ doSimLoop(EventQueue *eventq)
|
||||||
assert(curTick() <= eventq->nextTick() &&
|
assert(curTick() <= eventq->nextTick() &&
|
||||||
"event scheduled in the past");
|
"event scheduled in the past");
|
||||||
|
|
||||||
Event *exit_event = eventq->serviceOne();
|
|
||||||
if (exit_event != NULL) {
|
|
||||||
return exit_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (async_event && testAndClearAsyncEvent()) {
|
if (async_event && testAndClearAsyncEvent()) {
|
||||||
// Take the event queue lock in case any of the service
|
// Take the event queue lock in case any of the service
|
||||||
// routines want to schedule new events.
|
// routines want to schedule new events.
|
||||||
std::lock_guard<EventQueue> lock(*eventq);
|
std::lock_guard<EventQueue> lock(*eventq);
|
||||||
async_event = false;
|
|
||||||
if (async_statdump || async_statreset) {
|
if (async_statdump || async_statreset) {
|
||||||
Stats::schedStatEvent(async_statdump, async_statreset);
|
Stats::schedStatEvent(async_statdump, async_statreset);
|
||||||
async_statdump = false;
|
async_statdump = false;
|
||||||
async_statreset = false;
|
async_statreset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (async_exit) {
|
|
||||||
async_exit = false;
|
|
||||||
exitSimLoop("user interrupt received");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (async_io) {
|
if (async_io) {
|
||||||
async_io = false;
|
async_io = false;
|
||||||
pollQueue.service();
|
pollQueue.service();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (async_exit) {
|
||||||
|
async_exit = false;
|
||||||
|
exitSimLoop("user interrupt received");
|
||||||
|
}
|
||||||
|
|
||||||
if (async_exception) {
|
if (async_exception) {
|
||||||
async_exception = false;
|
async_exception = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Event *exit_event = eventq->serviceOne();
|
||||||
|
if (exit_event != NULL) {
|
||||||
|
return exit_event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not reached... only exit is return on SimLoopExitEvent
|
// not reached... only exit is return on SimLoopExitEvent
|
||||||
|
|
Loading…
Reference in a new issue