fix: thread switch gets back into the isr routine but iret does not return to the correct frame
This commit is contained in:
@ -22,19 +22,18 @@ struct tcb *create_thread(struct pcb *process, void (*routine)(void))
|
||||
// set esp to "skip" the 4 GPRs and eip later to be used as the context
|
||||
// of the thread
|
||||
new_tcb->esp = new_tcb->esp0 + STACK_SIZE - 5 * 4;
|
||||
memcpy(new_tcb->esp + 4, routine, 4);
|
||||
new_tcb->esp[4] = (uint32_t)routine;
|
||||
new_tcb->process = process;
|
||||
new_tcb->next = NULL;
|
||||
new_tcb->state = NEW;
|
||||
|
||||
struct tcb *it = process->thread_list;
|
||||
if (it) {
|
||||
while (it)
|
||||
it = it->next;
|
||||
it = new_tcb;
|
||||
}
|
||||
else {
|
||||
if (process->thread_list == NULL) {
|
||||
process->thread_list = new_tcb;
|
||||
} else {
|
||||
struct tcb *it = process->thread_list;
|
||||
while (it->next)
|
||||
it = it->next;
|
||||
it->next = new_tcb;
|
||||
}
|
||||
|
||||
return new_tcb;
|
||||
|
||||
Reference in New Issue
Block a user