|
AquilaOS documentation
How it works, and its code
|
Go to the source code of this file.
Data Structures | |
| struct | thread |
| A thread. More... | |
Macros | |
| #define | THREAD_FILES_HELD 4 |
| the open files its system call holds (file_hold()), let go of when the call returns, or when the thread is killed | |
Enumerations | |
| enum | state_t { RUNNABLE , ISLEEP , USLEEP , ZOMBIE } |
Functions | |
| int | thread_new (struct proc *proc, struct thread **rthread) |
| Makes a new thread in a process. | |
| 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(). | |
| 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. | |
| void | thread_files_release (struct thread *thread) |
| Lets go of the open files a thread's system call held, when the call returns or the thread is killed. | |
| #define THREAD_FILES_HELD 4 |
the open files its system call holds (file_hold()), let go of when the call returns, or when the thread is killed
Definition at line 79 of file thread.h.
Referenced by file_hold().
| 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().
| void thread_files_release | ( | struct thread * | thread | ) |
Lets go of the open files a thread's system call held, when the call returns or the thread is killed.
| thread | the thread |
Definition at line 99 of file file.c.
References file_put(), thread::files, thread::files_held, and thread_files_release().
Referenced by proc_kill(), proc_threads_end(), syscall_dispatch(), and thread_files_release().
| 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().