mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 09:06:32 +00:00
bugfix: 修复多核启动时,自旋锁持有计数错误的问题
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
#define preempt_disable() \
|
||||
do \
|
||||
{ \
|
||||
--(current_pcb->preempt_count);\
|
||||
++(current_pcb->preempt_count);\
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
@ -19,5 +19,5 @@ do \
|
||||
#define preempt_enable() \
|
||||
do \
|
||||
{ \
|
||||
++(current_pcb->preempt_count);\
|
||||
--(current_pcb->preempt_count);\
|
||||
}while(0)
|
||||
|
@ -152,15 +152,15 @@ union proc_union
|
||||
{ \
|
||||
.state = PROC_UNINTERRUPTIBLE, \
|
||||
.flags = PF_KTHREAD, \
|
||||
.preempt_count = 0, \
|
||||
.signal = 0, \
|
||||
.cpu_id = 0, \
|
||||
.mm = &initial_mm, \
|
||||
.thread = &initial_thread, \
|
||||
.addr_limit = 0xffffffffffffffff, \
|
||||
.pid = 0, \
|
||||
.virtual_runtime = 0, \
|
||||
.signal = 0, \
|
||||
.priority = 2, \
|
||||
.preempt_count = 0, \
|
||||
.cpu_id = 0, \
|
||||
.virtual_runtime = 0, \
|
||||
.fds = {0}, \
|
||||
.next_pcb = &proc, \
|
||||
.parent_pcb = &proc, \
|
||||
|
@ -55,6 +55,7 @@ void smp_init()
|
||||
continue;
|
||||
|
||||
spin_lock(&multi_core_starting_lock);
|
||||
preempt_enable(); // 由于ap处理器的pcb与bsp的不同,因此ap处理器放锁时,bsp的自旋锁持有计数不会发生改变,需要手动恢复preempt count
|
||||
current_starting_cpu = proc_local_apic_structs[i]->local_apic_id;
|
||||
|
||||
kdebug("[core %d] acpi processor UID=%d, APIC ID=%d, flags=%#010lx", i, proc_local_apic_structs[i]->ACPI_Processor_UID, proc_local_apic_structs[i]->local_apic_id, proc_local_apic_structs[i]->flags);
|
||||
@ -95,7 +96,7 @@ void smp_init()
|
||||
{
|
||||
*(ul *)(phys_2_virt(global_CR3) + i) = 0UL;
|
||||
}
|
||||
|
||||
kdebug("init proc's preempt_count=%ld", current_pcb->preempt_count);
|
||||
kinfo("Successfully cleaned page table remapping!\n");
|
||||
}
|
||||
|
||||
@ -147,10 +148,11 @@ void smp_ap_start()
|
||||
initial_proc[proc_current_cpu_id] = current_pcb;
|
||||
|
||||
load_TR(10 + current_starting_cpu * 2);
|
||||
current_pcb->preempt_count = 0;
|
||||
|
||||
// kdebug("IDT_addr = %#018lx", phys_2_virt(IDT_Table));
|
||||
spin_unlock(&multi_core_starting_lock);
|
||||
current_pcb->preempt_count = 0;
|
||||
preempt_disable();// 由于ap处理器的pcb与bsp的不同,因此ap处理器放锁时,需要手动恢复preempt count
|
||||
sti();
|
||||
|
||||
while (1)
|
||||
|
Reference in New Issue
Block a user