Skip to content
Snippets Groups Projects
Commit c8dc75d3 authored by mandersch's avatar mandersch
Browse files

Fix a Bug where a preempted task would not be continued if stopped at a...

Fix a Bug where a preempted task would not be continued if stopped at a specific moment, Add l_entry field to plan_entry struct to keep track of the last finished task
parent b28facd7
No related branches found
No related tags found
No related merge requests found
...@@ -129,7 +129,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq, ...@@ -129,7 +129,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
struct pb_rq *pb = &(rq->pb); struct pb_rq *pb = &(rq->pb);
unsigned long flags; unsigned long flags;
pb->l_entry = pb->c_entry;
current_mode = pb->mode; current_mode = pb->mode;
next_mode = determine_next_mode_pb(rq); next_mode = determine_next_mode_pb(rq);
...@@ -139,7 +139,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq, ...@@ -139,7 +139,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
printk("SWITCHING MODES\n"); printk("SWITCHING MODES\n");
pb->count_admin_cycles = 0; pb->count_admin_cycles = 0;
pb->count_pb_cycles = 0; pb->count_pb_cycles = 0;
// Push last onn-plan task back in its corresponding runqueue // Push last non-plan task back in its corresponding runqueue
if (next_mode == PB_EXEC_MODE) { if (next_mode == PB_EXEC_MODE) {
// Necessary to manage the preempted task // Necessary to manage the preempted task
printk("PUT OLD TASK BACK IN RQ\n"); printk("PUT OLD TASK BACK IN RQ\n");
...@@ -147,7 +147,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq, ...@@ -147,7 +147,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
} }
} }
if ((current_mode == PB_EXEC_MODE && !pb->is_preempted) || (pb->is_preempted && !pb->is_in_critical)) { if (current_mode == PB_EXEC_MODE && !pb->is_preempted) {
unsigned int c_entry_curr; unsigned int c_entry_curr;
u64 perf_counter; u64 perf_counter;
u64 counter_diff; u64 counter_diff;
...@@ -196,8 +196,6 @@ static struct task_struct * pick_next_task_pb(struct rq *rq, ...@@ -196,8 +196,6 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
pb->is_in_critical = false; pb->is_in_critical = false;
printk("DONE"); printk("DONE");
} }
pb->is_preempted = false;
// EXEC Mode is next, so we return our next task to be executed // EXEC Mode is next, so we return our next task to be executed
if (next_mode == PB_EXEC_MODE) { if (next_mode == PB_EXEC_MODE) {
...@@ -207,6 +205,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq, ...@@ -207,6 +205,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
} else if (current_mode == PB_DISABLED_MODE) { } else if (current_mode == PB_DISABLED_MODE) {
printk("Switching from disabled to EXEC\n"); printk("Switching from disabled to EXEC\n");
} }
pb->is_preempted = false;
picked = pb->plan[pb->c_entry].task_struct; picked = pb->plan[pb->c_entry].task_struct;
} }
...@@ -240,7 +239,10 @@ static void task_tick_pb(struct rq *rq, struct task_struct *p, int queued) ...@@ -240,7 +239,10 @@ static void task_tick_pb(struct rq *rq, struct task_struct *p, int queued)
if (determine_next_mode_pb(rq) != PB_EXEC_MODE && pb->mode == PB_EXEC_MODE && !pb->is_preempted && !pb->is_in_critical) { if (determine_next_mode_pb(rq) != PB_EXEC_MODE && pb->mode == PB_EXEC_MODE && !pb->is_preempted && !pb->is_in_critical) {
printk("Reschudling in task_tick_pb"); printk("Reschudling in task_tick_pb");
if (pb->l_entry != pb->c_entry){
// If the currrent task is not the last finished one, that means its unfinished and thus we set the preemtped flag
pb->is_preempted = true; pb->is_preempted = true;
}
resched_curr(rq); resched_curr(rq);
} }
} }
......
...@@ -545,6 +545,7 @@ struct pb_rq ...@@ -545,6 +545,7 @@ struct pb_rq
struct plan_entry *plan; // plan (used to be proxy_task) struct plan_entry *plan; // plan (used to be proxy_task)
unsigned int size; // size of the plan unsigned int size; // size of the plan
unsigned int c_entry; // index of currently executed entry unsigned int c_entry; // index of currently executed entry
unsigned int l_entry; // index of last finished task, neccessary or preemption management
u64 n_pb_cycles; // amount of timer ticks before admin tasks are allowed to run u64 n_pb_cycles; // amount of timer ticks before admin tasks are allowed to run
u64 count_pb_cycles; // current timer tick count for PB tasks u64 count_pb_cycles; // current timer tick count for PB tasks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment