7d99745ff9
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>
46 lines
1.6 KiB
C
46 lines
1.6 KiB
C
#include "../include/syscalls.h"
|
|
|
|
#define STDOUT 1
|
|
|
|
unsigned strlen(const char* str)
|
|
{
|
|
unsigned len = 0;
|
|
while (*str)
|
|
{
|
|
++len;
|
|
++str;
|
|
}
|
|
return len;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
const unsigned char* path = "/qwerty.txt";
|
|
const unsigned char* msg = "Suki Suki Daisuki Kekkon Shiyo, my honey!";
|
|
|
|
unsigned char buf[128];
|
|
|
|
// ── open file ─────────────────────────────
|
|
unsigned long fd = syscall(SYS_OPEN, (long)path, 0, 0, 0, 0, 0);
|
|
|
|
// ── write message ─────────────────────────
|
|
syscall(SYS_WRITE, fd, (long)msg, strlen(msg), 0, 0, 0);
|
|
|
|
// ── close ────────────────────────────────
|
|
syscall(SYS_CLOSE, fd, 0, 0, 0, 0, 0);
|
|
|
|
// ── reopen ───────────────────────────────
|
|
fd = syscall(SYS_OPEN, (long)path, 0, 0, 0, 0, 0);
|
|
|
|
// ── read into buffer ─────────────────────
|
|
unsigned long n = syscall(SYS_READ, fd, (unsigned long)buf, sizeof(buf), 0, 0, 0);
|
|
|
|
// ── close ────────────────────────────────
|
|
syscall(SYS_CLOSE, fd, 0, 0, 0, 0, 0);
|
|
|
|
// ── print buffer to stdout ───────────────
|
|
syscall(SYS_WRITE, STDOUT, (unsigned long)buf, n, 0, 0, 0);
|
|
|
|
// ── done ────────────────────────────────
|
|
while (1);
|
|
} |