Skip to content

Commit

Permalink
[Kernel] Scheduler won’t choose a task that’s currently running on an…
Browse files Browse the repository at this point in the history
…other core
  • Loading branch information
codyd51 committed Jan 24, 2023
1 parent f774737 commit b75a5a8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
6 changes: 0 additions & 6 deletions kernel/kernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ static void _kernel_bootstrap_part2(void) {

// TODO(PT): Only mask the PIT once we're sure all cores have calibrated
// TODO(PT): Pull the PIT IRQ line somehow
/*
uint32_t start = ms_since_boot();
printf("BSP spinlooping...\n");
while (ms_since_boot() < start + 3000) {}
printf("BSP will mask PIT.\n");
*/

smp_core_continue();
}
4 changes: 2 additions & 2 deletions kernel/kernel/multitasking/tasks/mlfq.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool mlfq_choose_task(task_small_t** out_task, uint32_t* out_quantum) {
mlfq_queue_t* q = array_m_lookup(_queues, i);
for (int j = 0; j < q->round_robin_tasks->size; j++) {
mlfq_ent_t* ent = array_l_lookup(q->round_robin_tasks, j);
if (ent->task->blocked_info.status == RUNNABLE && ent->task->cpu_id == cpu_id()) {
if (ent->task->blocked_info.status == RUNNABLE && !ent->task->is_currently_executing /*&& ent->task->cpu_id == cpu_id()*/) {
*out_task = ent->task;
*out_quantum = ent->ttl_remaining;
ent->last_schedule_start = ms_since_boot();
Expand Down Expand Up @@ -225,7 +225,7 @@ void mlfq_print(void) {
blocked_reason = "unknown";
break;
}
printf("[%d %s %s] ", ent->task->id, ent->task->name, blocked_reason);
printf("[[Cpu%d,Pid%d] %s %s] ", ent->task->cpu_id, ent->task->id, ent->task->name, blocked_reason);
}
printf("\n");
}
Expand Down
1 change: 1 addition & 0 deletions kernel/kernel/multitasking/tasks/task_small.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef struct task_small {
char* managing_parent_service_name;

uintptr_t cpu_id;
bool is_currently_executing;
} task_small_t;

void tasking_init_small();
Expand Down

0 comments on commit b75a5a8

Please sign in to comment.