AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
thread Struct Reference

A thread. More...

#include <thread.h>

Data Fields

tid_t tid
 the thread's ID, in its process
state_t state
 its state
struct proc * owner
 its process
const char * name
 A kernel thread's (process 0's): its name, and what it runs.
void(*) kentry (void *arg)
void * karg
uintptr_t stack
 its user stack
uintptr_t stack_base
size_t stack_size
struct list_node run_link
 it's on the ready list (sched.c) while it's ready to run, or on the wait queue it sleeps on (waitq); run_link.list says which
struct waitq * waitq
int syscall_nr
 the system call it's in (the last one it made), to restart it
int restarting
 whether the call is a restart (a stop interrupted it, and no handler ran); restart_until is the deadline it had, which a call that sleeps until a deadline (nanosleep, poll, select) keeps
uint64_t restart_until
void * exit_value
 what the thread exited with (thread_exit()), for thread_join()
int sig_oldmask_set
 in sigsuspend() or pselect(): the signal mask they replaced, which the handler's frame keeps (sigreturn() restores it), or which is restored on the way out
sigset_t sig_oldmask
uint64_t sleep_until
 when it waits with a deadline (sched_wait()): the deadline, in arch_rtime_ns() time
uintptr_t fault_addr
 the address of its last fault, the si_addr of the signal it raised
struct list_node timer_link
 it's on the timer's list while it waits with a deadline
struct file * files [THREAD_FILES_HELD]
int files_held
void * arch
 the architecture's own data: its registers, its kernel stack
int spawned
 whether it has run yet
int urgent
 it runs before the others once woken, as soon as the interrupt that woke it returns (sched_thread_wake()): the network's thread
struct poll_reg * poll_regs
 in select() or poll(): what it waits for (poll_register()), and where it sleeps meanwhile
struct waitq poll_wait
int killed
 it was killed (proc_threads_end()) while it ran on another CPU: it frees itself there, when that CPU next enters the kernel; its owner is NULL if its process goes too (sched_thread_killed())

Detailed Description

A thread.

Definition at line 23 of file thread.h.

Field Documentation

◆ arch

◆ exit_value

void* thread::exit_value

what the thread exited with (thread_exit()), for thread_join()

Definition at line 58 of file thread.h.

Referenced by sys_thread_join().

◆ fault_addr

uintptr_t thread::fault_addr

the address of its last fault, the si_addr of the signal it raised

Definition at line 72 of file thread.h.

Referenced by deliver(), and deliver().

◆ files

struct file* thread::files[THREAD_FILES_HELD]

Definition at line 80 of file thread.h.

Referenced by file_hold(), and thread_files_release().

◆ files_held

int thread::files_held

Definition at line 81 of file thread.h.

Referenced by file_hold(), and thread_files_release().

◆ karg

void* thread::karg

Definition at line 36 of file thread.h.

Referenced by kthread_create().

◆ kentry

void(*) thread::kentry(void *arg)

Definition at line 35 of file thread.h.

Referenced by kthread_create().

◆ killed

int thread::killed

it was killed (proc_threads_end()) while it ran on another CPU: it frees itself there, when that CPU next enters the kernel; its owner is NULL if its process goes too (sched_thread_killed())

Definition at line 101 of file thread.h.

Referenced by proc_threads_end().

◆ name

const char* thread::name

A kernel thread's (process 0's): its name, and what it runs.

Definition at line 34 of file thread.h.

Referenced by kthread_create(), and procfs_proc_status().

◆ owner

◆ poll_regs

struct poll_reg* thread::poll_regs

in select() or poll(): what it waits for (poll_register()), and where it sleeps meanwhile

Definition at line 95 of file thread.h.

Referenced by poll_register(), and poll_unregister().

◆ poll_wait

struct waitq thread::poll_wait

Definition at line 96 of file thread.h.

◆ restart_until

uint64_t thread::restart_until

Definition at line 55 of file thread.h.

◆ restarting

int thread::restarting

whether the call is a restart (a stop interrupted it, and no handler ran); restart_until is the deadline it had, which a call that sleeps until a deadline (nanosleep, poll, select) keeps

Definition at line 54 of file thread.h.

Referenced by aarch64_return_to_user(), and x86_return_to_user().

◆ run_link

struct list_node thread::run_link

it's on the ready list (sched.c) while it's ready to run, or on the wait queue it sleeps on (waitq); run_link.list says which

Definition at line 45 of file thread.h.

Referenced by proc_threads_end(), procfs_proc_status(), sched_thread_ready(), sched_thread_wake(), schedule(), thread_wakeup(), and waitq_wakeup_nopoll().

◆ sig_oldmask

sigset_t thread::sig_oldmask

Definition at line 64 of file thread.h.

Referenced by aarch64_return_to_user(), deliver(), deliver(), sys_sigsuspend(), and x86_return_to_user().

◆ sig_oldmask_set

int thread::sig_oldmask_set

in sigsuspend() or pselect(): the signal mask they replaced, which the handler's frame keeps (sigreturn() restores it), or which is restored on the way out

Definition at line 63 of file thread.h.

Referenced by aarch64_return_to_user(), deliver(), deliver(), sys_sigsuspend(), and x86_return_to_user().

◆ sleep_until

uint64_t thread::sleep_until

when it waits with a deadline (sched_wait()): the deadline, in arch_rtime_ns() time

Definition at line 68 of file thread.h.

Referenced by sched_timer_tick().

◆ spawned

int thread::spawned

whether it has run yet

Definition at line 87 of file thread.h.

Referenced by arch_syscall_return(), kthread_create(), proc_execve(), proc_fork(), and sched_thread_spawn().

◆ stack

uintptr_t thread::stack

its user stack

Definition at line 39 of file thread.h.

Referenced by sys_thread_create(), and thread_create().

◆ stack_base

uintptr_t thread::stack_base

Definition at line 40 of file thread.h.

Referenced by binfmt_fmt_load().

◆ stack_size

size_t thread::stack_size

Definition at line 41 of file thread.h.

Referenced by binfmt_fmt_load().

◆ state

state_t thread::state

◆ syscall_nr

int thread::syscall_nr

the system call it's in (the last one it made), to restart it

Definition at line 49 of file thread.h.

Referenced by x86_return_to_user().

◆ tid

tid_t thread::tid

the thread's ID, in its process

Definition at line 25 of file thread.h.

Referenced by procfs_proc_status(), sys_thread_create(), sys_thread_join(), and thread_new().

◆ timer_link

struct list_node thread::timer_link

it's on the timer's list while it waits with a deadline

Definition at line 75 of file thread.h.

Referenced by procfs_proc_status(), sched_timer_cancel(), and sched_timer_tick().

◆ urgent

int thread::urgent

it runs before the others once woken, as soon as the interrupt that woke it returns (sched_thread_wake()): the network's thread

Definition at line 91 of file thread.h.

Referenced by netif_register(), and sched_thread_wake().

◆ waitq

struct waitq* thread::waitq

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