|
AquilaOS documentation
How it works, and its code
|
Threads: making one in a process, and ending one. More...
#include <core/system.h>#include <core/arch.h>#include <core/panic.h>#include <sys/proc.h>#include <sys/sched.h>#include <sys/signal.h>#include <ds/queue.h>Go to the source code of this file.
Functions | |
| int | thread_new (struct proc *proc, struct thread **ref) |
| Makes a new thread in a process. | |
| int | thread_kill (struct thread *thread) |
| Releases what a thread holds (its poll() registrations, its CPU state and kernel stack) and makes it a zombie. | |
| int | thread_create (struct thread *thread, uintptr_t stack, uintptr_t entry, uintptr_t uentry, uintptr_t arg, uintptr_t attr, struct thread **new_thread) |
| Makes a new thread in the process of an existing one, for pthread_create(). | |
Threads: making one in a process, and ending one.
Running them is the scheduler's (sys/sched.c), sleeping and waking up the wait queues' (sys/waitq.c), and the CPU state the architecture's (arch_thread_create(), arch_thread_kill()).
Definition in file thread.c.
| int thread_create | ( | struct thread * | thread, |
| uintptr_t | stack, | ||
| uintptr_t | entry, | ||
| uintptr_t | uentry, | ||
| uintptr_t | arg, | ||
| uintptr_t | attr, | ||
| struct thread ** | new_thread ) |
Makes a new thread in the process of an existing one, for pthread_create().
The new thread is set up to start at uentry in user mode, but isn't made ready to run: the caller does that.
| thread | a thread of the process to add the new one to |
| stack | the new thread's user stack |
| entry | where the new thread starts in user mode (the C library's thread start) |
| uentry | the function the C library's start calls |
| arg | the argument it passes to uentry |
| attr | not used |
| new_thread | if not NULL, set to the new thread |
Definition at line 86 of file thread.c.
References arch_thread_create(), kfree(), NULL, thread::owner, thread::stack, thread_create(), thread_new(), and proc::threads.
Referenced by sys_thread_create(), and thread_create().
| int thread_kill | ( | struct thread * | thread | ) |
Releases what a thread holds (its poll() registrations, its CPU state and kernel stack) and makes it a zombie.
The thread's structure itself is freed by its caller, or by thread_join().
| thread | the thread, which must not be running |
Definition at line 59 of file thread.c.
References arch_thread_kill(), poll_unregister(), thread::state, thread_kill(), and ZOMBIE.
Referenced by __arch_cur_thread_kill(), proc_threads_end(), and thread_kill().
Makes a new thread in a process.
The thread has an ID but no CPU state yet, and doesn't run: thread_create() and fork() set it up.
| proc | the process the thread belongs to |
| ref | if not NULL, set to the new thread |
Definition at line 27 of file thread.c.
References kfree(), kmalloc(), M_ZERO, NULL, thread::owner, thread_new(), proc::threads, thread::tid, and proc::tid_last.
Referenced by kthread_create(), proc_new(), thread_create(), and thread_new().