mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +00:00
LibPthread: Start working on a POSIX threading library
This patch adds pthread_create() and pthread_exit(), which currently simply wrap our existing create_thread() and exit_thread() syscalls. LibThread is also ported to using LibPthread.
This commit is contained in:
parent
4fe2ee0221
commit
69ca9cfd78
16 changed files with 89 additions and 31 deletions
|
@ -2807,7 +2807,7 @@ int Process::thread_count() const
|
|||
return count;
|
||||
}
|
||||
|
||||
int Process::sys$create_thread(int (*entry)(void*), void* argument)
|
||||
int Process::sys$create_thread(void* (*entry)(void*), void* argument)
|
||||
{
|
||||
if (!validate_read((const void*)entry, sizeof(void*)))
|
||||
return -EFAULT;
|
||||
|
@ -2822,11 +2822,13 @@ int Process::sys$create_thread(int (*entry)(void*), void* argument)
|
|||
return thread->tid();
|
||||
}
|
||||
|
||||
void Process::sys$exit_thread(int code)
|
||||
void Process::sys$exit_thread(void* code)
|
||||
{
|
||||
UNUSED_PARAM(code);
|
||||
cli();
|
||||
if (¤t->process().main_thread() == current) {
|
||||
sys$exit(code);
|
||||
// FIXME: For POSIXy reasons, we should only sys$exit once *all* threads have exited.
|
||||
sys$exit(0);
|
||||
return;
|
||||
}
|
||||
current->set_state(Thread::State::Dying);
|
||||
|
|
|
@ -204,8 +204,8 @@ public:
|
|||
int sys$sched_setparam(pid_t pid, const struct sched_param* param);
|
||||
int sys$sched_getparam(pid_t pid, struct sched_param* param);
|
||||
int sys$restore_signal_mask(u32 mask);
|
||||
int sys$create_thread(int (*)(void*), void*);
|
||||
void sys$exit_thread(int code);
|
||||
int sys$create_thread(void* (*)(void*), void*);
|
||||
void sys$exit_thread(void*);
|
||||
int sys$rename(const char* oldpath, const char* newpath);
|
||||
int sys$systrace(pid_t);
|
||||
int sys$mknod(const char* pathname, mode_t, dev_t);
|
||||
|
|
|
@ -67,7 +67,7 @@ int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
|
|||
if (function == SC_exit)
|
||||
process.sys$exit((int)arg1);
|
||||
else
|
||||
process.sys$exit_thread((int)arg1);
|
||||
process.sys$exit_thread((void*)arg1);
|
||||
ASSERT_NOT_REACHED();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ build_targets="$build_targets ../Libraries/LibC"
|
|||
build_targets="$build_targets ../Libraries/LibCore"
|
||||
build_targets="$build_targets ../Libraries/LibIPC"
|
||||
build_targets="$build_targets ../Libraries/LibThread"
|
||||
build_targets="$build_targets ../Libraries/LibPthread"
|
||||
|
||||
# Build IPC servers before their client code to ensure the IPC definitions are available.
|
||||
build_targets="$build_targets ../Servers/AudioServer"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue