BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / 99d3ce8c89383289c5183f690345c2621e7bbd48 / task / switch.S

// Related

Nucleus

Barry Priority preemption in scheduler 99d3ce8 (3 years, 1 month ago)
/*
 * This file contains the context switch routine.  This routine will switch the
 * current context, but will not save any state, so it should only be called by
 * the scheduler.  Since the stack and page directory will get switched, care
 * must be taken to read and set the registers in the correct order.
 */

.section .text
.global context_switch
.type copy_page_frame, @function
.align 4
context_switch:
.code32
	cli
	mov 4(%esp), %ecx
	mov 8(%esp), %eax
	mov 12(%esp), %ebx
	mov 16(%esp), %esi
	mov 20(%esp), %edi
	mov 24(%esp), %ebp
	mov 28(%esp), %esp
	test %eax, %eax
	je 1f
	mov %eax, %cr3
1:
	sti
	jmp *%ecx