|
PatchworkOS
|
Thread of execution structure. More...
#include <thread.h>
Public Member Functions | |
| _Atomic (thread_state_t) state | |
Data Fields | |
| list_entry_t | entry |
| The entry for the scheduler and wait system. | |
| process_t * | process |
| The parent process that the thread executes within. | |
| list_entry_t | processEntry |
| The entry for the parent process. | |
| tid_t | id |
The thread id, unique within a process_t. | |
| errno_t | error |
| stack_pointer_t | kernelStack |
| The kernel stack of the thread. | |
| stack_pointer_t | userStack |
| The user stack of the thread. | |
| sched_thread_ctx_t | sched |
| wait_thread_ctx_t | wait |
| simd_ctx_t | simd |
| note_queue_t | notes |
| syscall_ctx_t | syscall |
| interrupt_frame_t | frame |
Thread of execution structure.
A thread_t represents an independent thread of execution within a process_t.
The position of a thread user stack is decided based on its thread id. The user stack of the thread with id 0 is located at the top of the lower half of the address space, the user stack is CONFIG_MAX_USER_STACK_PAGES pages long, and below it is the guard page. Below that is the user stack of the thread with id 1, below that is its guard page, it then continues like that for however many threads there are.
The kernel stack works the same way, but instead starts just under the kernel code and data section, at the top of the kernel stacks region and each stack is CONFIG_MAX_KERNEL_STACK_PAGES pages long.
| thread_t::_Atomic | ( | thread_state_t | ) |
The current state of the thread, used to prevent race conditions and make debugging easier.
| list_entry_t thread_t::entry |
The entry for the scheduler and wait system.
Definition at line 56 of file thread.h.
Referenced by sched_queues_push(), thread_init(), wait_block_finalize(), wait_timer_handler(), and wait_unblock_thread().
| errno_t thread_t::error |
The last error that occurred while the thread was running, specified using errno codes.
Definition at line 67 of file thread.h.
Referenced by _errno_get(), exception_handler(), panic(), and thread_init().
| interrupt_frame_t thread_t::frame |
The threads interrupt frame is used to save the values in the CPU registers such that the scheduler can continue executing the thread later on.
Definition at line 79 of file thread.h.
Referenced by init_early(), loader_process_entry(), loader_spawn(), loader_thread_create(), sched_cpu_ctx_init(), thread_get_interrupt_frame(), thread_init(), thread_load(), thread_save(), and trampoline_c_entry().
| tid_t thread_t::id |
The thread id, unique within a process_t.
Definition at line 59 of file thread.h.
Referenced by exception_handler(), note_interrupt_handler(), panic(), sched_done_with_boot_thread(), sched_invoke(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), thread_free(), thread_get_boot(), thread_init(), and thread_send_note().
| stack_pointer_t thread_t::kernelStack |
The kernel stack of the thread.
Definition at line 68 of file thread.h.
Referenced by init_early(), loader_spawn(), panic(), sched_cpu_ctx_init(), thread_handle_page_fault(), thread_init(), and trampoline_c_entry().
| note_queue_t thread_t::notes |
Definition at line 73 of file thread.h.
Referenced by note_interrupt_handler(), thread_init(), thread_is_note_pending(), and thread_send_note().
| process_t* thread_t::process |
The parent process that the thread executes within.
Definition at line 57 of file thread.h.
Referenced by exception_handler(), init_process_spawn(), loader_load_program(), loader_process_entry(), loader_setup_argv(), note_interrupt_handler(), panic(), sched_compute_actual_priority(), sched_compute_time_slice(), sched_done_with_boot_thread(), sched_invoke(), sched_process(), sched_process_exit(), sched_process_unsafe(), stack_pointer_deinit(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), thread_copy_from_user(), thread_copy_from_user_pathname(), thread_copy_from_user_terminated(), thread_copy_to_user(), thread_free(), thread_get_boot(), thread_handle_page_fault(), thread_init(), thread_load(), thread_load_atomic_from_user(), thread_send_note(), vmm_map_bootloader_lower_half(), and vmm_unmap_bootloader_lower_half().
| list_entry_t thread_t::processEntry |
The entry for the parent process.
Definition at line 58 of file thread.h.
Referenced by thread_free(), and thread_init().
| sched_thread_ctx_t thread_t::sched |
Definition at line 70 of file thread.h.
Referenced by init_early(), sched_compute_actual_priority(), sched_compute_time_slice(), sched_done_with_boot_thread(), sched_invoke(), sched_load_balance(), sched_push(), sched_push_new_thread(), sched_queues_push(), sched_should_notify(), sched_update_recent_idle_time(), sched_yield(), and thread_init().
| simd_ctx_t thread_t::simd |
Definition at line 72 of file thread.h.
Referenced by thread_free(), thread_init(), thread_load(), and thread_save().
| syscall_ctx_t thread_t::syscall |
Definition at line 74 of file thread.h.
Referenced by thread_init(), and thread_load().
| stack_pointer_t thread_t::userStack |
The user stack of the thread.
Definition at line 69 of file thread.h.
Referenced by loader_setup_argv(), loader_thread_create(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), SYSCALL_DEFINE(), thread_copy_from_user(), thread_copy_from_user_pathname(), thread_copy_from_user_terminated(), thread_copy_to_user(), thread_handle_page_fault(), thread_init(), and thread_load_atomic_from_user().
| wait_thread_ctx_t thread_t::wait |
Definition at line 71 of file thread.h.
Referenced by thread_init(), wait_block_commit(), wait_block_finalize(), wait_block_setup(), wait_remove_wait_entries(), wait_timer_handler(), wait_unblock(), and wait_unblock_thread().