feature: add threads (WIP)

This commit is contained in:
2021-11-17 13:05:51 +02:00
parent 6bb4f38edc
commit adb95ac52e
16 changed files with 746 additions and 367 deletions
+2
View File
@@ -4,6 +4,8 @@ pub const SYS_EX_NANOSLEEP: usize = 129;
pub const SYS_EX_SIGNAL: usize = 130;
pub const SYS_EX_SIGRETURN: usize = 131;
pub const SYS_EX_KILL: usize = 132;
pub const SYS_EX_CLONE: usize = 133;
pub const SYS_EX_YIELD: usize = 134;
pub const SYS_EXIT: usize = 1;
pub const SYS_READ: usize = 2;
+26
View File
@@ -271,6 +271,32 @@ pub fn sys_ex_kill(pid: SignalDestination, signum: Signal) -> Result<(), Errno>
})
}
#[inline(always)]
pub fn sys_ex_clone(entry: usize, stack: usize, arg: usize) -> Result<usize, Errno> {
Errno::from_syscall(unsafe {
syscall!(
abi::SYS_EX_CLONE,
argn!(entry),
argn!(stack),
argn!(arg)
)
})
}
#[inline(always)]
pub fn sys_ex_yield() {
unsafe {
syscall!(abi::SYS_EX_YIELD);
}
}
#[inline(always)]
pub fn sys_ex_undefined() {
unsafe {
syscall!(0);
}
}
#[inline(always)]
pub fn sys_select(
read_fds: Option<&mut FdSet>,
+1 -1
View File
@@ -47,6 +47,6 @@ impl Errno {
impl From<usize> for Errno {
fn from(u: usize) -> Errno {
todo!()
unsafe { core::mem::transmute(u as u32) }
}
}