PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
thread.h File Reference
#include <kernel/cpu/gdt.h>
#include <kernel/cpu/interrupt.h>
#include <kernel/cpu/simd.h>
#include <kernel/cpu/stack_pointer.h>
#include <kernel/cpu/syscall.h>
#include <kernel/drivers/perf.h>
#include <kernel/fs/path.h>
#include <kernel/ipc/note.h>
#include <kernel/sched/sched.h>
#include <kernel/sched/wait.h>
#include <kernel/sync/rcu.h>
#include <kernel/utils/ref.h>
#include <sys/list.h>
#include <sys/proc.h>
Include dependency graph for thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  thread_t
 Thread of execution structure. More...
 

Typedefs

typedef struct process process_t
 
typedef struct thread thread_t
 
typedef void(* thread_kernel_entry_t) (void *arg)
 Kernel thread entry point function type.
 

Enumerations

enum  thread_state_t {
  THREAD_PARKED = 0 , THREAD_ACTIVE , THREAD_PRE_BLOCK , THREAD_BLOCKED ,
  THREAD_UNBLOCKING , THREAD_DYING
}
 Thread state enum. More...
 

Functions

thread_tthread_new (process_t *process)
 Creates a new thread structure.
 
void thread_free (thread_t *thread)
 Frees a thread structure.
 
tid_t thread_kernel_create (thread_kernel_entry_t entry, void *arg)
 Creates a new thread that runs in kernel mode and submits it to the scheduler.
 
static thread_tthread_current (void)
 Retrieves the currently running thread.
 
static thread_tthread_current_unsafe (void)
 Retrieves the currently running thread without disabling interrupts.
 
static thread_tthread_idle (void)
 Retrieves the idle thread for the current CPU.
 
static thread_tthread_idle_unsafe (void)
 Retrieves the idle thread for the current CPU without disabling interrupts.
 
void thread_save (thread_t *thread, const interrupt_frame_t *frame)
 Save state to a thread.
 
void thread_load (thread_t *thread, interrupt_frame_t *frame)
 Load state from a thread.
 
bool thread_is_note_pending (thread_t *thread)
 Check if a thread has a note pending.
 
uint64_t thread_send_note (thread_t *thread, const char *string)
 Send a note to a thread.
 
uint64_t thread_copy_from_user (thread_t *thread, void *dest, const void *userSrc, uint64_t length)
 Safely copy data from user space.
 
uint64_t thread_copy_to_user (thread_t *thread, void *userDest, const void *src, uint64_t length)
 Safely copy data to user space.
 
uint64_t thread_copy_from_user_terminated (thread_t *thread, const void *userArray, const void *terminator, uint8_t objectSize, uint64_t maxCount, void **outArray, uint64_t *outCount)
 Safely copy a null-terminated array of objects from user space.
 
uint64_t thread_copy_from_user_string (thread_t *thread, char *dest, const char *userSrc, uint64_t size)
 Safely copy a string from user space.
 
uint64_t thread_copy_from_user_pathname (thread_t *thread, pathname_t *pathname, const char *userPath)
 Safely copy a string from user space and use it to initialize a pathname.
 
uint64_t thread_copy_from_user_string_array (thread_t *thread, const char **user, char ***out, uint64_t *outAmount)
 Safely copy a null-terminated array of strings and their contents from user space into a string vector.
 
uint64_t thread_load_atomic_from_user (thread_t *thread, atomic_uint64_t *userObj, uint64_t *outValue)
 Atomically load a 64-bit value from a user-space atomic variable.
 
_NORETURN void thread_jump (thread_t *thread)
 Jump to a thread by calling thread_load() and then loading its interrupt frame.
 

Typedef Documentation

◆ process_t

typedef struct process process_t

Definition at line 19 of file thread.h.

◆ thread_t

typedef struct thread thread_t

Definition at line 20 of file thread.h.