KallistiOS git master
Independent SDK for the Sega Dreamcast
|
Structure describing one running thread. More...
#include <thread.h>
Public Member Functions | |
LIST_ENTRY (kthread) t_list | |
Thread list handle. | |
TAILQ_ENTRY (kthread) thdq | |
Run/Wait queue handle. | |
TAILQ_ENTRY (kthread) timerq | |
Timer queue handle (if applicable). | |
Data Fields | ||
irq_context_t | context | |
Register store – used to save thread context. | ||
tid_t | tid | |
Kernel thread id. | ||
prio_t | prio | |
Dynamic priority. | ||
prio_t | real_prio | |
Static priority: 0..PRIO_MAX (higher means lower priority). | ||
kthread_flags_t | flags | |
Thread flags. | ||
kthread_state_t | state | |
Process state. | ||
void * | wait_obj | |
Generic wait target, if waiting. | ||
const char * | wait_msg | |
Generic wait message, if waiting. | ||
void(* | wait_callback )(void *obj) | |
Wait timeout callback. | ||
uint64_t | wait_timeout | |
Next scheduled time. | ||
struct { | ||
uint64_t scheduled | ||
time when the thread became active More... | ||
uint64_t total | ||
total running CPU time for thread More... | ||
} | cpu_time | |
Per-Thread CPU Time. | ||
char | label [KTHREAD_LABEL_SIZE] | |
Thread label. | ||
char | pwd [KTHREAD_PWD_SIZE] | |
Current file system path. | ||
void * | stack | |
Thread private stack. | ||
size_t | stack_size | |
Size of the thread's stack, in bytes. | ||
int | thd_errno | |
Thread errno variable. | ||
struct _reent | thd_reent | |
Our reent struct for newlib. | ||
struct kthread_tls_kv_list | tls_list | |
OS-level thread-local storage. | ||
tcbhead_t * | tcbhead | |
Compiler-level thread-local storage. | ||
void * | rv | |
Return value of the thread function. | ||
Related Symbols | |
(Note that these are not member symbols.) | |
kthread_t * | thd_by_tid (tid_t tid) |
Given a thread ID, locates the thread structure. | |
void | thd_add_to_runnable (kthread_t *t, bool front_of_line) |
Enqueue a process in the runnable queue. | |
int | thd_remove_from_runnable (kthread_t *thd) |
Removes a thread from the runnable queue, if it's there. | |
kthread_t * | thd_create (bool detach, void *(*routine)(void *param), void *param) |
Create a new thread. | |
kthread_t * | thd_create_ex (const kthread_attr_t *__RESTRICT attr, void *(*routine)(void *param), void *param) |
Create a new thread with the specified set of attributes. | |
int | thd_destroy (kthread_t *thd) |
Brutally kill the given thread. | |
void | thd_schedule_next (kthread_t *thd) |
Force a given thread to the front of the queue. | |
int | thd_set_prio (kthread_t *thd, prio_t prio) |
Set a thread's priority value. | |
kthread_t * | thd_get_current (void) |
Retrieve the current thread's kthread struct. | |
const char * | thd_get_label (kthread_t *thd) |
Retrieve the thread's label. | |
void | thd_set_label (kthread_t *thd, const char *__RESTRICT label) |
Set the thread's label. | |
const char * | thd_get_pwd (kthread_t *thd) |
Retrieve the thread's current working directory. | |
void | thd_set_pwd (kthread_t *thd, const char *__RESTRICT pwd) |
Set the thread's current working directory. | |
int * | thd_get_errno (kthread_t *thd) |
Retrieve a pointer to the thread errno. | |
struct _reent * | thd_get_reent (kthread_t *thd) |
Retrieve a pointer to the thread reent struct. | |
uint64_t | thd_get_cpu_time (kthread_t *thd) |
Retrieves the thread's elapsed CPU time. | |
int | thd_join (kthread_t *thd, void **value_ptr) |
Wait for a thread to exit. | |
int | thd_detach (kthread_t *thd) |
Detach a joinable thread. | |
int | thd_each (int(*cb)(kthread_t *thd, void *user_data), void *data) |
Iterate all threads and call the passed callback for each. | |
Structure describing one running thread.
Each thread has one of these structures assigned to it, which holds all the data associated with the thread. There are various functions to manipulate the data in here, so you shouldn't generally do so manually.
kthread_t::LIST_ENTRY | ( | kthread | ) |
Thread list handle.
Not a function.
kthread_t::TAILQ_ENTRY | ( | kthread | ) |
Run/Wait queue handle.
Once again, not a function.
kthread_t::TAILQ_ENTRY | ( | kthread | ) |
Timer queue handle (if applicable).
Also not a function.
irq_context_t kthread_t::context |
Register store – used to save thread context.
struct { ... } kthread_t::cpu_time |
Per-Thread CPU Time.
kthread_flags_t kthread_t::flags |
Thread flags.
char kthread_t::label[KTHREAD_LABEL_SIZE] |
Thread label.
This value is used when printing out a user-readable process listing.
prio_t kthread_t::prio |
Dynamic priority.
char kthread_t::pwd[KTHREAD_PWD_SIZE] |
Current file system path.
prio_t kthread_t::real_prio |
Static priority: 0..PRIO_MAX (higher means lower priority).
void* kthread_t::rv |
Return value of the thread function.
This is only used in joinable threads.
uint64_t kthread_t::scheduled |
time when the thread became active
void* kthread_t::stack |
Thread private stack.
This should be a pointer to the base of a stack page.
size_t kthread_t::stack_size |
Size of the thread's stack, in bytes.
kthread_state_t kthread_t::state |
Process state.
tcbhead_t* kthread_t::tcbhead |
Compiler-level thread-local storage.
int kthread_t::thd_errno |
Thread errno variable.
struct _reent kthread_t::thd_reent |
Our reent struct for newlib.
tid_t kthread_t::tid |
Kernel thread id.
struct kthread_tls_kv_list kthread_t::tls_list |
OS-level thread-local storage.
uint64_t kthread_t::total |
total running CPU time for thread
void(* kthread_t::wait_callback) (void *obj) |
Wait timeout callback.
If the genwait times out while waiting, this function will be called. This allows hooks for things like fixing up semaphore count values, etc.
obj | The object that we were waiting on. |
const char* kthread_t::wait_msg |
Generic wait message, if waiting.
void* kthread_t::wait_obj |
Generic wait target, if waiting.
uint64_t kthread_t::wait_timeout |
Next scheduled time.
This value is used for sleep and timed block operations. This value is in milliseconds since the start of timer_ms_gettime(). This should be enough for something like 2 million years of wait time. ;)