PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
thread_t Struct Reference

Thread of execution structure. More...

#include <thread.h>

Collaboration diagram for thread_t:

Public Member Functions

 _Atomic (thread_state_t) state
 

Data Fields

process_tprocess
 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_client_t sched
 
wait_client_t wait
 
simd_ctx_t simd
 
note_queue_t notes
 
syscall_ctx_t syscall
 
perf_thread_ctx_t perf
 
interrupt_frame_t frame
 

Detailed Description

Thread of execution structure.

A thread_t represents an independent thread of execution within a process_t.

Thread Stacks

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.

Definition at line 62 of file thread.h.

Member Function Documentation

◆ _Atomic()

thread_t::_Atomic ( thread_state_t  )

The current state of the thread, used to prevent race conditions and make debugging easier.

Field Documentation

◆ process

process_t* thread_t::process

The parent process that the thread executes within.

Definition at line 64 of file thread.h.

◆ processEntry

list_entry_t thread_t::processEntry

The entry for the parent process.

Definition at line 65 of file thread.h.

◆ id

tid_t thread_t::id

The thread id, unique within a process_t.

Definition at line 66 of file thread.h.

◆ error

errno_t thread_t::error

The last error that occurred while the thread was running, specified using errno codes.

Definition at line 74 of file thread.h.

◆ kernelStack

stack_pointer_t thread_t::kernelStack

The kernel stack of the thread.

Definition at line 75 of file thread.h.

◆ userStack

stack_pointer_t thread_t::userStack

The user stack of the thread.

Definition at line 76 of file thread.h.

◆ sched

sched_client_t thread_t::sched

Definition at line 77 of file thread.h.

◆ wait

wait_client_t thread_t::wait

Definition at line 78 of file thread.h.

◆ simd

simd_ctx_t thread_t::simd

Definition at line 79 of file thread.h.

◆ notes

note_queue_t thread_t::notes

Definition at line 80 of file thread.h.

◆ syscall

syscall_ctx_t thread_t::syscall

Definition at line 81 of file thread.h.

◆ perf

perf_thread_ctx_t thread_t::perf

Definition at line 82 of file thread.h.

◆ frame

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 87 of file thread.h.


The documentation for this struct was generated from the following file: