Support whole kernel lock. TODO: fix spawn.

This commit is contained in:
TXuian
2024-03-14 14:28:11 +08:00
parent 01f4d45e0c
commit 3dc6d58bdb
11 changed files with 43 additions and 28 deletions

View File

@@ -48,14 +48,12 @@ bool swi_distributer_init(struct SwiDispatcherRightGroup* _right_group)
extern void context_switch(struct context**, struct context*);
void software_irq_dispatch(struct trapframe* tf)
{
bool is_my_lock = false;
if (whole_kernel_lock.owner_cpu != cur_cpuid()) {
spinlock_lock(&whole_kernel_lock);
is_my_lock = true;
}
assert(p_intr_driver != NULL);
p_intr_driver->cpu_irq_disable();
spinlock_lock(&whole_kernel_lock);
// DEBUG("CPU %d in kernel %s %d\n", cur_cpuid(), __func__, __LINE__);
// get current task
struct TaskMicroDescriptor* cur_task = cur_cpu()->task;
/// @todo: Handle dead task
@@ -82,8 +80,7 @@ void software_irq_dispatch(struct trapframe* tf)
ERROR("Exit reaches");
}
if (is_my_lock) {
spinlock_unlock(&whole_kernel_lock);
}
// DEBUG("CPU %d out kernel %s %d\n", cur_cpuid(), __func__, __LINE__);
spinlock_unlock(&whole_kernel_lock);
p_intr_driver->cpu_irq_enable();
}