wip: thread and processes handle
This commit is contained in:
31
src/multitasking/switch_to_thread.s
Normal file
31
src/multitasking/switch_to_thread.s
Normal file
@ -0,0 +1,31 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .text
|
||||
.global switch_thread
|
||||
|
||||
switch_thread:
|
||||
push ebx
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
|
||||
mov eax, [current_tcb]
|
||||
|
||||
// save the current stack pointer to the old stack
|
||||
mov [eax+0], esp
|
||||
|
||||
// stack pointer + the 4 regs pushed
|
||||
// and + 1 to get the argument (next thread)
|
||||
mov esi, [esp+(4+1)*4]
|
||||
mov [current_tcb], esi
|
||||
|
||||
mov eax, [current_tcb]
|
||||
|
||||
mov esp, [eax+0] // get esp
|
||||
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
pop ebx
|
||||
|
||||
iret
|
||||
Reference in New Issue
Block a user