[SMP] SMP synchronization and scheduling
This commit is contained in:
@@ -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++)
|
||||
|
||||
@@ -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
16
kernel/cpu/sync.S
Normal 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
|
||||
Reference in New Issue
Block a user