[SMP] SMP synchronization and scheduling

This commit is contained in:
2016-11-18 09:36:01 +01:00
parent 8961ae33eb
commit 474914ab1e
12 changed files with 69 additions and 18 deletions

View File

@@ -62,7 +62,9 @@ void cpu_init()
all_ap_started = 1;
vmm_set_page(0, TRAMPOLINE_ADDR, 0, 0);
pmm_free(page);
// Keep the GDT mapped for now
/* vmm_set_page(0, TRAMPOLINE_GDT, 0, 0); */
/* pmm_free(page); */
debug_info("CPU - Status\n");
for(unsigned int i = 0; i < num_cpu; i++)

View File

@@ -49,5 +49,7 @@ void ap_start()
while(!all_ap_started);
cpu_t *cpu = get_cpu();
debug_ok("STARTED CPU:%x\n", cpu->id);
schedule();
debug_error("PANIC: SMP - This line should be unreachable\n");
for(;;)asm("hlt");
}

16
kernel/cpu/sync.S Normal file
View File

@@ -0,0 +1,16 @@
.intel_syntax noprefix
.global spin_lock
spin_lock:
mov rdx, rdi
mov rax, 0x0
mov rcx, 0x1
.retry:
xor rax, rax
lock cmpxchg [rdx], cl
jnz .retry
ret
.global spin_unlock
spin_unlock:
movq [rdi], 0x0
ret