sched: Implement basic scheduling and signal handling system

Note: this is probably 25% broken, but it works right now as written, so I hope it all works.

- Added a new scheduler header file (scheduler.h) defining task structures, scheduling policies, and signal handling mechanisms.
- Integrated scheduling functions into the syscall interface, including SYS_GETPID, SYS_GETPPID, SYS_EXIT, SYS_SCHED_YIELD, SYS_NICE, SYS_KILL, SYS_SIGACTION, SYS_SIGPROCMASK, SYS_SCHED_GETSCHEDULER, and SYS_SCHED_SETSCHEDULER.
- Updated syscall handler to manage new scheduling-related syscalls and signal actions.

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-04-26 22:46:28 -04:00
parent 336af1c2ad
commit 7d99745ff9
20 changed files with 1561 additions and 53 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
+14 -4
View File
@@ -4,16 +4,26 @@
#define SYS_WRITE 1
#define SYS_OPEN 2
#define SYS_CLOSE 3
#define SYS_SCHED_YIELD 24
static inline long syscall(long num, long a1, long a2, long a3)
static inline long syscall(long num,
unsigned long a1,
unsigned long a2,
unsigned long a3,
unsigned long a4,
unsigned long a5,
unsigned long a6)
{
long ret;
asm volatile (
"mov %4, %%r10\n"
"mov %5, %%r8\n"
"mov %6, %%r9\n"
"syscall"
: "=a"(ret)
: "a"(num), "D"(a1), "S"(a2), "d"(a3)
: "a"(num), "D"(a1), "S"(a2), "d"(a3),
"r"(a4), "r"(a5), "r"(a6)
: "r10", "r8", "r9", "rcx", "r11", "memory"
);
return ret;
}
+10 -10
View File
@@ -15,31 +15,31 @@ unsigned strlen(const char* str)
void main()
{
const char* path = "/qwerty.txt";
const char* msg = "Suki Suki Daisuki Kekkon Shiyo, my honey!";
const unsigned char* path = "/qwerty.txt";
const unsigned char* msg = "Suki Suki Daisuki Kekkon Shiyo, my honey!";
char buf[128];
unsigned char buf[128];
// ── open file ─────────────────────────────
long fd = syscall(SYS_OPEN, (long)path, 0, 0);
unsigned long fd = syscall(SYS_OPEN, (long)path, 0, 0, 0, 0, 0);
// ── write message ─────────────────────────
syscall(SYS_WRITE, fd, (long)msg, strlen(msg));
syscall(SYS_WRITE, fd, (long)msg, strlen(msg), 0, 0, 0);
// ── close ────────────────────────────────
syscall(SYS_CLOSE, fd, 0, 0);
syscall(SYS_CLOSE, fd, 0, 0, 0, 0, 0);
// ── reopen ───────────────────────────────
fd = syscall(SYS_OPEN, (long)path, 0, 0);
fd = syscall(SYS_OPEN, (long)path, 0, 0, 0, 0, 0);
// ── read into buffer ─────────────────────
long n = syscall(SYS_READ, fd, (long)buf, sizeof(buf));
unsigned long n = syscall(SYS_READ, fd, (unsigned long)buf, sizeof(buf), 0, 0, 0);
// ── close ────────────────────────────────
syscall(SYS_CLOSE, fd, 0, 0);
syscall(SYS_CLOSE, fd, 0, 0, 0, 0, 0);
// ── print buffer to stdout ───────────────
syscall(SYS_WRITE, STDOUT, (long)buf, n);
syscall(SYS_WRITE, STDOUT, (unsigned long)buf, n, 0, 0, 0);
// ── done ────────────────────────────────
while (1);