From 69cd4f248d70e5f676c4ced50f9064e0b17c9a7c Mon Sep 17 00:00:00 2001 From: pjht Date: Mon, 20 Jul 2020 11:24:09 -0500 Subject: [PATCH] Kernel thread creation can now take a pid and an argument --- kernel/cpu/i386/isr.c | 4 ++-- kernel/cpu/i386/tasking.c | 6 +++--- kernel/cpu/tasking.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/cpu/i386/isr.c b/kernel/cpu/i386/isr.c index c5d08e2..d57b8cb 100644 --- a/kernel/cpu/i386/isr.c +++ b/kernel/cpu/i386/isr.c @@ -210,7 +210,7 @@ void isr_handler(registers_t* r) { r->ebx=(uint32_t)tasking_get_errno_address(); break; case SYSCALL_GET_PID: - r->ebx=(pid_t)getPID(); + r->ebx=(pid_t)tasking_getPID(); break; case SYSCALL_ALLOC_MEM: if ((void*)r->ecx==NULL) { @@ -251,7 +251,7 @@ void isr_handler(registers_t* r) { memcpy((char*)r->ebx,initrd,initrd_sz); break; case SYSCALL_NEW_THREAD: - tasking_new_thread((void*)r->ebx); + tasking_new_thread((void*)r->ebx,tasking_getPID(),0,0); break; default: break; diff --git a/kernel/cpu/i386/tasking.c b/kernel/cpu/i386/tasking.c index 1b91332..4147ca3 100644 --- a/kernel/cpu/i386/tasking.c +++ b/kernel/cpu/i386/tasking.c @@ -159,7 +159,7 @@ char tasking_isPrivleged() { return currentThread->process->priv; } -pid_t getPID() { +pid_t tasking_getPID() { return currentThread->process->pid; } @@ -167,8 +167,8 @@ int* tasking_get_errno_address() { return ¤tThread->errno; } -void tasking_new_thread(void* start) { - tasking_createTask(start,NULL,0,0,0,0,getPID(),1); +void tasking_new_thread(void* start,pid_t pid,char param_exists,uint32_t param_arg) { + tasking_createTask(start,NULL,0,param_exists,param_arg,0,pid,1); } void switch_to_thread(Thread* thread) { diff --git a/kernel/cpu/tasking.h b/kernel/cpu/tasking.h index 930afbc..38a3acf 100644 --- a/kernel/cpu/tasking.h +++ b/kernel/cpu/tasking.h @@ -9,9 +9,9 @@ void tasking_createTask(void* eip,void* cr3,char kmode,char param1_exists,uint32_t param1_arg,char param2_exists,uint32_t param2_arg,char isThread); void tasking_init(); char tasking_isPrivleged(); -pid_t getPID(); +pid_t tasking_getPID(); int* tasking_get_errno_address(); -void tasking_new_thread(void* start); +void tasking_new_thread(void* start,pid_t pid,char param_exists,uint32_t param_arg); void tasking_exit(uint8_t code); void tasking_block(ThreadState newstate);