Kernel/LibC: Implement sched_yield
This commit is contained in:
parent
5549696c3a
commit
9066e62a97
|
@ -182,6 +182,7 @@ namespace Kernel
|
|||
BAN::ErrorOr<long> sys_sigpending(sigset_t* set);
|
||||
BAN::ErrorOr<long> sys_sigprocmask(int how, const sigset_t* set, sigset_t* oset);
|
||||
|
||||
BAN::ErrorOr<long> sys_yield();
|
||||
BAN::ErrorOr<long> sys_pthread_create(const pthread_attr_t* __restrict attr, void (*entry)(void*), void* arg);
|
||||
BAN::ErrorOr<long> sys_pthread_exit(void* value);
|
||||
BAN::ErrorOr<long> sys_pthread_self();
|
||||
|
|
|
@ -2084,6 +2084,12 @@ namespace Kernel
|
|||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_yield()
|
||||
{
|
||||
Processor::yield();
|
||||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_pthread_create(const pthread_attr_t* __restrict attr, void (*entry)(void*), void* arg)
|
||||
{
|
||||
if (attr != nullptr)
|
||||
|
|
|
@ -20,6 +20,7 @@ set(LIBC_SOURCES
|
|||
pthread.cpp
|
||||
pwd.cpp
|
||||
scanf_impl.cpp
|
||||
sched.cpp
|
||||
setjmp.cpp
|
||||
signal.cpp
|
||||
stdio.cpp
|
||||
|
|
|
@ -90,6 +90,7 @@ __BEGIN_DECLS
|
|||
O(SYS_FSYNC, fsync) \
|
||||
O(SYS_SYMLINKAT, symlinkat) \
|
||||
O(SYS_HARDLINKAT, hardlinkat) \
|
||||
O(SYS_YIELD, yield) \
|
||||
O(SYS_PTHREAD_CREATE, pthread_create) \
|
||||
O(SYS_PTHREAD_EXIT, pthread_exit) \
|
||||
O(SYS_PTHREAD_SELF, pthread_self) \
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#include <sched.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int sched_yield(void)
|
||||
{
|
||||
return syscall(SYS_YIELD);
|
||||
}
|
Loading…
Reference in New Issue