Skip to content

Commit

Permalink
sched: check thread exit status when signals are raised
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 20, 2024
1 parent 99ef106 commit e0b8afc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,15 @@ void schedule() {
current->status = THREAD_QUEUED;

signalHandle(t);
t->status = THREAD_RUNNING;
t->time = schedTimeslice(t, t->priority);
t->cpu = cpu;
releaseLock(&lock);
platformSwitchContext(t);

if(t->status == THREAD_QUEUED) {
// check status again because the signal handler may terminate a thread
t->status = THREAD_RUNNING;
t->time = schedTimeslice(t, t->priority);
t->cpu = cpu;
releaseLock(&lock);
platformSwitchContext(t);
}
}

t = t->next;
Expand Down

0 comments on commit e0b8afc

Please sign in to comment.