Implement waiting for process, CE add command cancelation, rctx many cpus
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m27s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m27s
This commit is contained in:
@@ -56,8 +56,6 @@ void bootmain (void) {
|
||||
devices_init ();
|
||||
vfs_init ();
|
||||
|
||||
struct reschedule_ctx rctx = {.cpu = NULL, .reschedule = false};
|
||||
|
||||
struct device* ramdisk = device_find ("RD");
|
||||
vfs_create_volume ("RD", VFS_TARFS, ramdisk, false);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <amd64/io.h>
|
||||
#include <aux/compiler.h>
|
||||
#include <irq/irq.h>
|
||||
#include <libk/lengthof.h>
|
||||
#include <libk/std.h>
|
||||
#include <libk/string.h>
|
||||
#include <mm/liballoc.h>
|
||||
@@ -160,11 +161,19 @@ static void intr_exception (struct saved_regs* regs) {
|
||||
regs->rbx);
|
||||
|
||||
if (regs->cs == (GDT_UCODE | 0x03)) {
|
||||
struct reschedule_ctx rctx = {.reschedule = false, .cpu = NULL};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
proc_kill (thiscpu->proc_current, &rctx);
|
||||
|
||||
if (rctx.reschedule)
|
||||
cpu_request_sched (rctx.cpu);
|
||||
bool do_thiscpu = false;
|
||||
for (size_t i = 0; i < lengthof (rctx.cpus); i++) {
|
||||
if (rctx.cpus[i] != NULL && rctx.cpus[i] != thiscpu)
|
||||
cpu_request_sched (rctx.cpus[i]);
|
||||
else
|
||||
do_thiscpu = true;
|
||||
}
|
||||
|
||||
if (do_thiscpu)
|
||||
cpu_request_sched (thiscpu);
|
||||
} else {
|
||||
__asm__ volatile ("cli");
|
||||
spin ();
|
||||
@@ -196,11 +205,19 @@ void intr_handler (void* stack_ptr) {
|
||||
if (irq == NULL)
|
||||
return;
|
||||
|
||||
struct reschedule_ctx rctx = {.reschedule = false, .cpu = NULL};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
irq->func (irq->arg, stack_ptr, &rctx);
|
||||
|
||||
if (rctx.reschedule)
|
||||
cpu_request_sched (rctx.cpu);
|
||||
bool do_thiscpu = false;
|
||||
for (size_t i = 0; i < lengthof (rctx.cpus); i++) {
|
||||
if (rctx.cpus[i] != NULL && rctx.cpus[i] != thiscpu)
|
||||
cpu_request_sched (rctx.cpus[i]);
|
||||
else
|
||||
do_thiscpu = true;
|
||||
}
|
||||
|
||||
if (do_thiscpu)
|
||||
cpu_request_sched (thiscpu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,26 @@ struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t ent
|
||||
}
|
||||
|
||||
void proc_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->done_sq.lock);
|
||||
|
||||
while (proc->done_sq.proc_list != NULL) {
|
||||
struct list_node_link* node = proc->done_sq.proc_list;
|
||||
struct proc_sq_entry* sq_entry = list_entry (node, struct proc_sq_entry, sq_link);
|
||||
struct proc* suspended_proc = sq_entry->proc;
|
||||
|
||||
spin_unlock (&proc->done_sq.lock);
|
||||
spin_unlock (&proc->lock);
|
||||
|
||||
proc_sq_resume (suspended_proc, sq_entry, rctx);
|
||||
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->done_sq.lock);
|
||||
}
|
||||
|
||||
spin_unlock (&proc->done_sq.lock);
|
||||
spin_unlock (&proc->lock);
|
||||
|
||||
proc_sqs_cleanup (proc);
|
||||
proc_mutexes_cleanup (proc, rctx);
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ static void smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
|
||||
atomic_fetch_sub (&cpu_counter, 1);
|
||||
|
||||
struct reschedule_ctx rctx = {.cpu = NULL, .reschedule = false};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
|
||||
struct proc* spin_proc = proc_from_file (VFS_KERNEL, "RD", "/spin", &rctx);
|
||||
proc_register (spin_proc, thiscpu, NULL);
|
||||
proc_register (spin_proc, thiscpu, &rctx);
|
||||
|
||||
spin_lock (&spin_proc->cpu->lock);
|
||||
do_sched (spin_proc, &spin_proc->cpu->lock);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <amd64/mm.h>
|
||||
#include <amd64/msr-index.h>
|
||||
#include <amd64/msr.h>
|
||||
#include <libk/lengthof.h>
|
||||
#include <libk/list.h>
|
||||
#include <libk/string.h>
|
||||
#include <mm/liballoc.h>
|
||||
@@ -37,7 +38,7 @@ uintptr_t syscall_dispatch (void* stack_ptr) {
|
||||
return -ST_SYSCALL_NOT_FOUND;
|
||||
}
|
||||
|
||||
struct reschedule_ctx rctx = {.reschedule = false, .cpu = NULL};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
|
||||
uintptr_t r =
|
||||
func (caller, regs, &rctx, regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9);
|
||||
@@ -50,8 +51,16 @@ uintptr_t syscall_dispatch (void* stack_ptr) {
|
||||
spin_unlock (&caller->lock);
|
||||
}
|
||||
|
||||
if (rctx.reschedule)
|
||||
cpu_request_sched (rctx.cpu);
|
||||
bool do_thiscpu = false;
|
||||
for (size_t i = 0; i < lengthof (rctx.cpus); i++) {
|
||||
if (rctx.cpus[i] != NULL && rctx.cpus[i] != thiscpu)
|
||||
cpu_request_sched (rctx.cpus[i]);
|
||||
else
|
||||
do_thiscpu = true;
|
||||
}
|
||||
|
||||
if (do_thiscpu)
|
||||
cpu_request_sched (thiscpu);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user