Skip to content
Snippets Groups Projects
Commit c07ff500 authored by Ollrogge's avatar Ollrogge
Browse files

pb.c: handle dead program before we start

parent 650a0ddc
No related branches found
No related tags found
No related merge requests found
......@@ -137,7 +137,7 @@ EXPORT_SYMBOL(set_pb_plan_entry);
// called by core.c sched_init
void init_pb_rq(struct pb_rq *pb_rq)
{
pb_rq->n_pb_cycles = 20;
pb_rq->n_pb_cycles = 100;
pb_rq->count_pb_cycles = 0;
pb_rq->n_admin_cycles = 20;
pb_rq->count_admin_cycles = 0;
......@@ -192,6 +192,20 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
next_mode = determine_next_mode_pb(rq);
pb->mode = next_mode;
/**
* This handles the case where the program to be run is dead before the
* pb scheduler starting executing
*/
if (current_mode == PB_DISABLED_MODE && current_mode != next_mode) {
if (pb->c_entry < pb->size && pb->plan[pb->c_entry].task_struct->state == TASK_DEAD) {
pb->mode = PB_DISABLED_MODE;
next_mode = PB_DISABLED_MODE;
picked = NULL;
pb->is_initialized = 0;
printk(KERN_WARNING "PLAN TERMINATED PREMATURELY \n");
}
}
if (current_mode != next_mode) {
printk("SWITCHING MODES\n");
pb->count_admin_cycles = 0;
......@@ -243,7 +257,7 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
* Don't schedule a task that is dead. (e.g. plan was incorrect and program finished quicker)
* todo: if we have multiple tasks structs just try the next plan entry
*/
if (pb->plan[pb->c_entry].task_struct->state == TASK_DEAD) {
if (pb->c_entry < pb->size && pb->plan[pb->c_entry].task_struct->state == TASK_DEAD) {
premature_finish = true;
}
......@@ -258,7 +272,13 @@ static struct task_struct * pick_next_task_pb(struct rq *rq,
next_mode = PB_DISABLED_MODE;
picked = NULL;
pb->is_initialized = 0;
printk(KERN_WARNING "PLAN DONE \n");
if (premature_finish) {
printk(KERN_WARNING "PLAN TERMINATED PREMATURELY \n");
}
else {
printk(KERN_WARNING "PLAN DONE \n");
}
}
pb->is_in_critical = false;
printk("DONE");
......
......@@ -3,16 +3,16 @@
int main(void)
{
// Make sure program is not finished before pb scheduler takes control
sleep(1);
unsigned int c = 0;
int a = 0;
int b = 0;
for (;b < 100; b++) {
// check if program runs && syscall to switch tasks
puts("loop");
for (;a < 100000; a++){asm("");}
// check if program runs && syscall to switch tasks
printf("loop run: %d \n", b);
usleep(1);
}
c++;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment