⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ThreadManager

Struct ThreadManager 

Source
pub struct ThreadManager { /* private fields */ }
Expand description

Thread management system

Implementations§

Source§

impl ThreadManager

Source

pub fn new() -> Self

Create a new thread manager

Source

pub fn create_thread( &self, params: ThreadCreateParams, process_id: ProcessId, ) -> Result<Arc<ThreadHandle>, KernelError>

Create a new thread

Source

pub fn get_thread(&self, thread_id: ThreadId) -> Option<Arc<ThreadHandle>>

Get thread handle by ID

Source

pub fn join_thread(&self, thread_id: ThreadId) -> Result<*mut u8, KernelError>

Join a thread (wait for it to complete)

Source

pub fn detach_thread(&self, thread_id: ThreadId) -> Result<(), KernelError>

Detach a thread

Source

pub fn cancel_thread(&self, thread_id: ThreadId) -> Result<(), KernelError>

Cancel a thread

Sets the cancellation flag on the thread. The thread should check is_cancel_requested() periodically and exit gracefully when cancelled. If the thread is blocked, it will be moved to Ready state to allow it to process the cancellation.

Source

pub fn exit_thread(&self, thread_id: ThreadId, exit_value: *mut u8)

Exit current thread

Source

pub fn set_thread_priority( &self, thread_id: ThreadId, _priority: ThreadPriority, ) -> Result<(), KernelError>

Set thread priority

Source

pub fn get_thread_priority( &self, thread_id: ThreadId, ) -> Result<ThreadPriority, KernelError>

Get thread priority

Source

pub fn set_cpu_affinity( &self, thread_id: ThreadId, cpu_mask: u64, ) -> Result<(), KernelError>

Set CPU affinity for thread

Source

pub fn create_tls_key( &self, destructor: Option<fn(*mut u8)>, ) -> Result<TlsKey, KernelError>

Create thread-local storage key

Source

pub fn delete_tls_key(&self, key: TlsKey) -> Result<(), KernelError>

Delete thread-local storage key

Source

pub fn set_tls_value( &self, thread_id: ThreadId, key: TlsKey, value: *mut u8, ) -> Result<(), KernelError>

Set thread-local storage value

Source

pub fn get_tls_value( &self, thread_id: ThreadId, key: TlsKey, ) -> Result<*mut u8, KernelError>

Get thread-local storage value

Source

pub fn get_current_thread_id(&self) -> Option<ThreadId>

Get current thread ID from scheduler

Source

pub fn list_threads(&self) -> Vec<ThreadId>

List all threads

Source

pub fn get_thread_stats( &self, thread_id: ThreadId, ) -> Result<ThreadStats, KernelError>

Get thread statistics

Trait Implementations§

Source§

impl Default for ThreadManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for ThreadManager

Source§

impl Sync for ThreadManager

Auto Trait Implementations§

§

impl !Freeze for ThreadManager

§

impl !RefUnwindSafe for ThreadManager

§

impl Unpin for ThreadManager

§

impl !UnwindSafe for ThreadManager

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.