-
Notifications
You must be signed in to change notification settings - Fork 4
I211 priority scheduling for signal handler #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,9 @@ namespace mythos { | |
| ASSERT(ec != nullptr); | ||
| MLOG_INFO(mlog::sched, "unbind", DVAR(ec->get())); | ||
| readyQueue.remove(ec); | ||
| priorityQueue.remove(ec); | ||
| current_handle.store(nullptr); | ||
| if(readyQueue.empty()){ | ||
| if(readyQueue.empty() && priorityQueue.empty()){ | ||
| MLOG_DETAIL(mlog::sched, "call idleSC"); | ||
| event::idleSC.emit(&paTask, home->getThreadID()); | ||
| }else{ | ||
|
|
@@ -67,11 +68,17 @@ namespace mythos { | |
|
|
||
| // add to the ready queue | ||
| readyQueue.remove(ec); /// @todo do not need to remove if already on the queue, just do nothing then. This needs additional information in handle_t of LinkedList | ||
| readyQueue.push(ec); | ||
| priorityQueue.remove(ec); /// @todo do not need to remove if already on the queue, just do nothing then. This needs additional information in handle_t of LinkedList | ||
| if(ec->get()->hasPriority()){ | ||
| priorityQueue.push(ec); | ||
| home->preempt(); // trigger reschedule to run priority ec | ||
| }else{ | ||
| readyQueue.push(ec); | ||
|
|
||
| // wake up the hardware thread if it has no execution context running | ||
| // or if if current ec got ready in case of race condition | ||
| if (current == nullptr || current == ec) home->preempt(); | ||
| // wake up the hardware thread if it has no execution context running | ||
| // or if if current ec got ready in case of race condition | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a running EC priority has been set to default from another hw thread (-> without interrupting it), this should also be enough to prevent the EC from running if there is another high priority EC waiting to run.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but I don't want to handle this special case. |
||
| if (current == nullptr || current == ec) home->preempt(); | ||
| } | ||
| } | ||
|
|
||
| void SchedulingContext::tryRunUser() | ||
|
|
@@ -81,24 +88,38 @@ namespace mythos { | |
| while (true) { | ||
| auto current = current_handle.load(); | ||
| if (current != nullptr) { | ||
| MLOG_DETAIL(mlog::sched, "try current", current, DVAR(current->get())); | ||
| auto loaded = current_ec->load(); | ||
| if (loaded != current->get()) { | ||
| if (loaded != nullptr) loaded->saveState(); | ||
| current->get()->loadState(); | ||
| if(current->get()->hasPriority() || priorityQueue.empty()){ | ||
| MLOG_DETAIL(mlog::sched, "try current", current, DVAR(current->get())); | ||
| auto loaded = current_ec->load(); | ||
| if (loaded != current->get()) { | ||
| if (loaded != nullptr) loaded->saveState(); | ||
| current->get()->loadState(); | ||
| } | ||
| current->get()->resume(); // if it returns, the ec is blocked | ||
| current_handle.store(nullptr); | ||
| }else{ | ||
| MLOG_DETAIL(mlog::sched, "try switching to priority EC from non-prio EC ", current, DVAR(current->get())); | ||
| readyQueue.push(current); | ||
| current_handle.store(nullptr); | ||
| } | ||
| current->get()->resume(); // if it returns, the ec is blocked | ||
| current_handle.store(nullptr); | ||
| } | ||
| MLOG_DETAIL(mlog::sched, "try from ready list"); | ||
| // something on the ready list? | ||
| auto next = readyQueue.pull(); | ||
| while (next != nullptr && !next->get()->isReady()) next = readyQueue.pull(); | ||
|
|
||
| MLOG_DETAIL(mlog::sched, "try from priority list"); | ||
| auto next = priorityQueue.pull(); | ||
| while (next != nullptr && !next->get()->isReady()) next = priorityQueue.pull(); | ||
| if (next == nullptr) { | ||
| // go sleeping because we don't have anything to run | ||
| MLOG_DETAIL(mlog::sched, "empty ready list, going to sleep"); | ||
| return; | ||
| } | ||
| MLOG_DETAIL(mlog::sched, "empty priority list, try ready list"); | ||
| // something on the ready list? | ||
| next = readyQueue.pull(); | ||
| while (next != nullptr && !next->get()->isReady()) next = readyQueue.pull(); | ||
| if (next == nullptr) { | ||
| // go sleeping because we don't have anything to run | ||
| MLOG_DETAIL(mlog::sched, "empty ready list, going to sleep"); | ||
| return; | ||
| } | ||
| }else{ | ||
| MLOG_DETAIL(mlog::sched, "found priority EC", next, DVAR(next->get())); | ||
| } | ||
| current_handle.store(next); | ||
| // now retry | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should limit that to a bool. See comment on interface.
setPriority(false)could be hard to interpret.