4.0 KiB
4.0 KiB
title | summary |
---|---|
thread.h | threading infrastructure |
thread_T
- struct
Name | Type | Description |
---|---|---|
state | cpu_state_T* | The last saved state of the thread ( -> context switching(reference needed)) |
cpu_time | uint64_t | The amount of cpu time the thread had. (currently the amount of context switches the thread had) |
stack | void* | The bottom of the threads stack |
stack_size | uint32_t | The size of the threads stack (in bytes) |
process | process_T* | The process, to which the thread belongs to |
global_prev | thread_T* | The previous thread in the scheduling queue (should only be accessed by the scheduler!) |
global_next | thread_T* | The next thread in the scheduling queue (should only be accessed by the scheduler!) |
local_prev | thread_T* | The previous thread of process (should only be accessed by the scheduler!) |
local_next | thread_T* | The next thread of process (should only be accessed by the scheduler!) |
local_id | uint32_t | The threads id in its process |
thread_spawn(function)
- function (thread_T*)
Allocates a thread_T and registers it in the scheduler. The thread starts execution at function. The for the thread allocated stack has a size of 16 KB (4 Pages). The thread still needs to be started with thread_start. Returns a pointer to the created thread.
thread_spawn_from_state(state)
- function (thread_T*)
Allocates a thread_T and registers it in the scheduler. The threads' cpu_state is copied from state. This won't allocate a stack for the stack. The thread still needs to be started with thread_start. Returns a pointer to the created thread. This function should be avoided.
thread_start(thread)
- function (void)
Starts/unpauses thread.
thread_pause(thread)
- function (void)
Pauses thread.
thread_kill(thread)
- function (void)
Kills thread. The threads stack and thread_T structure will be freed.