schedrelease() syscall for more efficient spinning

This commit is contained in:
2025-09-19 23:38:08 +02:00
parent e01d8d5e1a
commit 1b5701a659
10 changed files with 49 additions and 1 deletions

17
kernel/syscall/sched.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdint.h>
#include "syscall.h"
#include "sched.h"
#include "proc/proc.h"
#include "spinlock/spinlock.h"
#include "errors.h"
#include "hal/hal.h"
int32_t SYSCALL0(sys_schedrelease) {
spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current;
spinlock_release(&PROCS.spinlock);
proc_sched((void *)INTR_CURRENT_FRAME);
return E_OK;
}

9
kernel/syscall/sched.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef SYSCALL_SCHED_H_
#define SYSCALL_SCHED_H_
#include <stdint.h>
#include "syscall.h"
int32_t SYSCALL0(sys_schedrelease);
#endif // SYSCALL_SCHED_H_

View File

@ -7,6 +7,7 @@
#include "ioctl.h"
#include "ipcpipe.h"
#include "mman.h"
#include "sched.h"
int32_t SYSCALL1(sys_debugprint, string) {
char *p = (char *)string;
@ -21,4 +22,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
[SYS_IPCPIPE] = &sys_ipcpipe,
[SYS_MMAN_MAP] = &sys_mman_map,
[SYS_MMAN_UNMAP] = &sys_mman_unmap,
[SYS_SCHEDRELEASE] = &sys_schedrelease,
};