mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 14:38:21 +00:00
syscalls: new thread syscall
This commit is contained in:
@@ -45,7 +45,8 @@ extern syscall_fchmod
|
|||||||
extern syscall_linkat
|
extern syscall_linkat
|
||||||
extern syscall_recvmsg
|
extern syscall_recvmsg
|
||||||
extern syscall_futex
|
extern syscall_futex
|
||||||
func_count equ 44
|
extern syscall_newthread
|
||||||
|
func_count equ 45
|
||||||
|
|
||||||
|
|
||||||
func_table:
|
func_table:
|
||||||
@@ -93,6 +94,7 @@ func_table:
|
|||||||
dq syscall_linkat
|
dq syscall_linkat
|
||||||
dq syscall_recvmsg
|
dq syscall_recvmsg
|
||||||
dq syscall_futex
|
dq syscall_futex
|
||||||
|
dq syscall_newthread
|
||||||
section .text
|
section .text
|
||||||
global asm_syscall_entry
|
global asm_syscall_entry
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#include <kernel/syscalls.h>
|
||||||
|
#include <kernel/sched.h>
|
||||||
|
#include <kernel/env.h>
|
||||||
|
#include <arch/cls.h>
|
||||||
|
|
||||||
|
syscallret syscall_newthread(void* nip, void* stack){
|
||||||
|
syscallret retv;
|
||||||
|
retv.ret = -1;
|
||||||
|
|
||||||
|
if(env_isset("nomultithread")){
|
||||||
|
retv.errno = ENOSYS;
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_t* thread = arch_getcls()->thread;
|
||||||
|
proc_t* proc = thread->proc;
|
||||||
|
|
||||||
|
thread_t* new = sched_newuthread(nip, THREAD_DEFAULT_KSTACK_SIZE, stack, proc, false, THREAD_PRIORITY_USER);
|
||||||
|
|
||||||
|
if(!new){
|
||||||
|
retv.errno = ENOMEM;
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
|
new->ctx = thread->ctx;
|
||||||
|
|
||||||
|
sched_queuethread(new);
|
||||||
|
|
||||||
|
retv.errno = 0;
|
||||||
|
retv.ret = new->tid;
|
||||||
|
|
||||||
|
return retv;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user