Verified Commit f5590bec authored by Felix Kopp's avatar Felix Kopp
Browse files

syscall: add sleep system call

parent 02ed1b57
......@@ -4,6 +4,7 @@
#define ARCH_SYS_read 0
#define ARCH_SYS_write 1
#define ARCH_SYS_sleep 2
/*
* This file is part of Ardix.
......
......@@ -12,6 +12,7 @@
enum syscall {
SYS_read = ARCH_SYS_read,
SYS_write = ARCH_SYS_write,
SYS_sleep = ARCH_SYS_sleep,
NSYSCALLS
};
......@@ -27,6 +28,7 @@ long sys_stub(void);
long sys_read(int fd, void *buf, size_t len);
long sys_write(int fd, const void *buf, size_t len);
long sys_sleep(unsigned long millis);
/*
* This file is part of Ardix.
......
......@@ -6,6 +6,7 @@
__shared ssize_t read(int fildes, void *buf, size_t nbyte);
__shared ssize_t write(int fildes, const void *buf, size_t nbyte);
__shared ssize_t sleep(unsigned long int millis);
/*
* This file is part of Ardix.
......
......@@ -57,7 +57,7 @@ int main(void)
while (true) {
printf("hello, world (%u)\n", print_count);
msleep(1000);
sleep(1000);
print_count++;
if (print_count % 2)
......
......@@ -180,6 +180,13 @@ void msleep(unsigned long int ms)
yield(TASK_SLEEP);
}
long sys_sleep(unsigned long int millis)
{
msleep(millis);
/* TODO: return actual milliseconds */
return 0;
}
/*
* This file is part of Ardix.
* Copyright (c) 2020, 2021 Felix Kopp <owo@fef.moe>.
......
......@@ -12,6 +12,7 @@ long (*const sys_table[NSYSCALLS])(sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
sysarg_t arg4, sysarg_t arg5, sysarg_t arg6) = {
sys_table_entry(SYS_read, sys_read),
sys_table_entry(SYS_write, sys_write),
sys_table_entry(SYS_sleep, sys_sleep),
};
long sys_stub(void)
......
......@@ -14,6 +14,11 @@ ssize_t write(int fildes, const void *buf, size_t nbyte)
return syscall(SYS_write, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte);
}
ssize_t sleep(unsigned long int millis)
{
return syscall(SYS_sleep, (sysarg_t)millis);
}
/*
* This file is part of Ardix.
* Copyright (c) 2020, 2021 Felix Kopp <owo@fef.moe>.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment