Should I preserve the general regs(eax,etc) in multitasking.
Posted: Tue Mar 09, 2021 6:33 pm
Google doesn't seem to help this time.
The Place to Start for Operating System Developers
http://f.osdev.org/
Code: Select all
task_switch:
movl 4(%esp), %eax # eax = old context
movl 8(%esp), %edx # edx = new context
# Save old context
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
# Switch stacks
movl %esp, (%eax) # *old context = esp
movl %edx, %esp # esp = new context
# Restore new context
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
Depends if you have cooperative multitasking or pre-emptive multitasking.clementttttttttt wrote:Google doesn't seem to help this time.