Redesign reschedule points, allow one operation to reschedule many cpus at once
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
This commit is contained in:
@@ -22,10 +22,9 @@
|
||||
#include <syscall/syscall.h>
|
||||
|
||||
#define DEFINE_SYSCALL(name) \
|
||||
uintptr_t name (struct proc* UNUSED proc, void* UNUSED regs, bool* UNUSED reschedule, \
|
||||
struct cpu** UNUSED reschedule_cpu, uintptr_t UNUSED a1, uintptr_t UNUSED a2, \
|
||||
uintptr_t UNUSED a3, uintptr_t UNUSED a4, uintptr_t UNUSED a5, \
|
||||
uintptr_t UNUSED a6)
|
||||
uintptr_t name (struct proc* UNUSED proc, void* UNUSED regs, struct reschedule_ctx* UNUSED rctx, \
|
||||
uintptr_t UNUSED a1, uintptr_t UNUSED a2, uintptr_t UNUSED a3, \
|
||||
uintptr_t UNUSED a4, uintptr_t UNUSED a5, uintptr_t UNUSED a6)
|
||||
|
||||
#define SYSRESULT(x) ((uintptr_t)(x))
|
||||
|
||||
@@ -50,8 +49,7 @@ static void* sys_get_user_buffer (struct proc* proc, uintptr_t uvaddr, size_t si
|
||||
|
||||
/* int quit (void) */
|
||||
DEFINE_SYSCALL (sys_quit) {
|
||||
if (proc_kill (proc, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_kill (proc, rctx);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -100,8 +98,7 @@ DEFINE_SYSCALL (sys_clone) {
|
||||
|
||||
int pid = new->pid;
|
||||
|
||||
if (proc_register (new, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_register (new, NULL, rctx);
|
||||
|
||||
return SYSRESULT (pid);
|
||||
}
|
||||
@@ -111,7 +108,7 @@ DEFINE_SYSCALL (sys_argument_ptr) { return proc->uvaddr_argument; }
|
||||
|
||||
/* int sched (void) */
|
||||
DEFINE_SYSCALL (sys_sched) {
|
||||
*reschedule = true;
|
||||
reschedule_list_append (rctx, thiscpu);
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
|
||||
@@ -136,8 +133,7 @@ DEFINE_SYSCALL (sys_mutex_delete) {
|
||||
if (mutex_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
if (proc_delete_resource (mutex_resource, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_delete_resource (mutex_resource, rctx);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -151,8 +147,7 @@ DEFINE_SYSCALL (sys_mutex_lock) {
|
||||
if (mutex_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
if (proc_mutex_lock (proc, &mutex_resource->u.mutex, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_mutex_lock (proc, &mutex_resource->u.mutex, rctx);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -166,8 +161,7 @@ DEFINE_SYSCALL (sys_mutex_unlock) {
|
||||
if (mutex_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
if (proc_mutex_unlock (proc, &mutex_resource->u.mutex, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_mutex_unlock (proc, &mutex_resource->u.mutex, rctx);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -193,10 +187,7 @@ DEFINE_SYSCALL (sys_mail_send) {
|
||||
if (mail_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
if (proc_mail_send (proc, &mail_resource->u.mail, reschedule_cpu, mesg, mesg_size) ==
|
||||
PROC_NEED_RESCHEDULE) {
|
||||
*reschedule = true;
|
||||
}
|
||||
proc_mail_send (proc, &mail_resource->u.mail, rctx, mesg, mesg_size);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -216,10 +207,7 @@ DEFINE_SYSCALL (sys_mail_receive) {
|
||||
if (mail_resource == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
if (proc_mail_receive (proc, &mail_resource->u.mail, reschedule_cpu, mesg, mesg_size) ==
|
||||
PROC_NEED_RESCHEDULE) {
|
||||
*reschedule = true;
|
||||
}
|
||||
proc_mail_receive (proc, &mail_resource->u.mail, rctx, mesg, mesg_size);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
@@ -264,15 +252,9 @@ DEFINE_SYSCALL (sys_device_do) {
|
||||
if (device == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
struct device_op_ctx op_ctx = {
|
||||
.proc = proc,
|
||||
.reschedule = reschedule,
|
||||
.reschedule_cpu = reschedule_cpu,
|
||||
};
|
||||
|
||||
spin_lock (&device->lock);
|
||||
|
||||
int ret = device->ops[cmd](device, &op_ctx, (void*)ka1, (void*)ka2, (void*)ka3, (void*)ka4);
|
||||
int ret = device->ops[cmd](device, proc, rctx, (void*)ka1, (void*)ka2, (void*)ka3, (void*)ka4);
|
||||
|
||||
spin_unlock (&device->lock);
|
||||
|
||||
@@ -310,8 +292,7 @@ DEFINE_SYSCALL (sys_exec) {
|
||||
int pid = new->pid;
|
||||
new->exec_pid = proc->pid;
|
||||
|
||||
if (proc_register (new, reschedule_cpu) == PROC_NEED_RESCHEDULE)
|
||||
*reschedule = true;
|
||||
proc_register (new, NULL, rctx);
|
||||
|
||||
return SYSRESULT (pid);
|
||||
}
|
||||
@@ -441,6 +422,9 @@ DEFINE_SYSCALL (sys_get_procgroup) {
|
||||
|
||||
struct proc* target_proc = proc_find_pid (pid);
|
||||
|
||||
if (target_proc == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
return SYSRESULT (target_proc->procgroup->pgid);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#ifndef _KERNEL_SYSCALL_SYSCALL_H
|
||||
#define _KERNEL_SYSCALL_SYSCALL_H
|
||||
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
struct cpu;
|
||||
|
||||
typedef uintptr_t (*syscall_handler_func_t) (struct proc* proc, void* regs, bool* reschedule,
|
||||
struct cpu** reschedule_cpu, uintptr_t a1,
|
||||
typedef uintptr_t (*syscall_handler_func_t) (struct proc* proc, void* regs,
|
||||
struct reschedule_ctx* rctx, uintptr_t a1,
|
||||
uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5,
|
||||
uintptr_t a6);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user