summaryrefslogtreecommitdiff
path: root/src/scheduler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/scheduler.rs')
-rw-r--r--src/scheduler.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/scheduler.rs b/src/scheduler.rs
index 0832049..dfd879b 100644
--- a/src/scheduler.rs
+++ b/src/scheduler.rs
@@ -158,9 +158,11 @@ impl<'a> Scheduler<'a> {
while let Ok(Some(mut task)) = self.bpf.dequeue_task() {
// The scheduler itself has to be scheduled regardless of its energy usage
if task.pid == self.own_pid {
+ task.vtime = 10;
self.task_queue.push_front(task);
continue;
}
+ // TODO: consider adjusting vtime for all processes
// Check if we've seen this task before
match self.managed_tasks.entry(task.pid) {
@@ -182,8 +184,13 @@ impl<'a> Scheduler<'a> {
}
std::collections::hash_map::Entry::Occupied(e) => {
// Get current budget for this task
- match e.get().read_budget() {
- 0 => self.no_budget_task_queue.push_back(task),
+ let slice_ns = e.get().update_runtime(task.sum_exec_runtime);
+ let new_budget = e.get().update_budget(Duration::from_nanos(slice_ns));
+ match new_budget {
+ x if x < 0 => {
+ task.weight = 0;
+ self.no_budget_task_queue.push_back(task)
+ }
x if x < 1000 => {
task.weight = 0;
self.task_queue.push_back(task)