wip: switch current_pcb and cr3 in switch_thread
This commit is contained in:
@ -24,4 +24,4 @@ struct tcb {
|
||||
|
||||
struct tcb *create_thread(struct pcb *process, void (*entry)(void));
|
||||
void delete_thread(struct tcb *thread);
|
||||
void switch_thread(uint32_t *esp);
|
||||
void switch_thread(struct tcb *thread_to_switch);
|
||||
|
||||
@ -39,8 +39,6 @@ void scheduler(uint32_t *esp)
|
||||
struct tcb *thread_to_switch = (struct tcb *)list_node->content;
|
||||
if (current_tcb)
|
||||
CURRENT_TCB->esp = esp;
|
||||
if (thread_to_switch->process != current_pcb)
|
||||
switch_process(thread_to_switch->process);
|
||||
current_tcb = list_node;
|
||||
switch_thread(thread_to_switch->esp);
|
||||
switch_thread(thread_to_switch);
|
||||
}
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
.intel_syntax noprefix
|
||||
.extern current_pcb
|
||||
|
||||
.section .text
|
||||
.global switch_process
|
||||
|
||||
switch_process:
|
||||
// change current_pcb global
|
||||
mov eax, [esp + 4]
|
||||
mov [current_pcb], eax
|
||||
|
||||
// reload cr3 with the new heap
|
||||
mov edx, [eax + 0]
|
||||
mov cr3, edx
|
||||
|
||||
ret
|
||||
@ -7,8 +7,20 @@
|
||||
switch_thread:
|
||||
|
||||
mov eax, [esp + 4]
|
||||
mov esp, eax
|
||||
mov esp, [eax]
|
||||
|
||||
mov edx, [eax + 16]
|
||||
cmp [current_pcb], edx
|
||||
je LABEL1
|
||||
|
||||
// change current_pcb
|
||||
mov [current_pcb], edx
|
||||
|
||||
// reload cr3 with the new heap
|
||||
mov edx, [edx]
|
||||
mov cr3, edx
|
||||
|
||||
LABEL1:
|
||||
pop eax
|
||||
mov ds, eax
|
||||
|
||||
|
||||
Reference in New Issue
Block a user