From f6fda869ead3aae97e73d2222bfc9fdfd837491e Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 30 Aug 2018 00:39:49 -0700 Subject: systemc: Keep track of more cases when we should be ready after resume. If a thread self suspends, it should be marked as ready after resuming. If a process was already ready when suspended, it should also be remarked as ready after resuming. Special care has to be taken in pre-initialization situations so that processes are put on the right lists, and whether a process is tracked is already marked as ready. Change-Id: I15da7d747db591785358d47781297468c5f9fd09 Reviewed-on: https://gem5-review.googlesource.com/c/12445 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/scheduler.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/systemc/core/scheduler.cc') diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index 46053b40f..9b431acba 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -200,6 +200,39 @@ Scheduler::ready(Process *p) scheduleReadyEvent(); } +void +Scheduler::resume(Process *p) +{ + if (initDone) + ready(p); + else + initList.pushLast(p); +} + +bool +Scheduler::suspend(Process *p) +{ + if (initDone) { + // After initialization, the only list we can be on is the ready list. + bool was_ready = (p->nextListNode != nullptr); + p->popListNode(); + return was_ready; + } else { + bool was_ready = false; + // Check the ready list to see if we find this process. + ListNode *n = readyList.nextListNode; + while (n != &readyList) { + if (n == p) { + was_ready = true; + break; + } + } + if (was_ready) + toFinalize.pushLast(p); + return was_ready; + } +} + void Scheduler::requestUpdate(Channel *c) { -- cgit v1.2.3