pub struct ThreadManager { /* private fields */ }Expand description
Thread management system
Implementations§
Source§impl ThreadManager
impl ThreadManager
Sourcepub fn create_thread(
&self,
params: ThreadCreateParams,
process_id: ProcessId,
) -> Result<Arc<ThreadHandle>, KernelError>
pub fn create_thread( &self, params: ThreadCreateParams, process_id: ProcessId, ) -> Result<Arc<ThreadHandle>, KernelError>
Create a new thread
Sourcepub fn get_thread(&self, thread_id: ThreadId) -> Option<Arc<ThreadHandle>>
pub fn get_thread(&self, thread_id: ThreadId) -> Option<Arc<ThreadHandle>>
Get thread handle by ID
Sourcepub fn join_thread(&self, thread_id: ThreadId) -> Result<*mut u8, KernelError>
pub fn join_thread(&self, thread_id: ThreadId) -> Result<*mut u8, KernelError>
Join a thread (wait for it to complete)
Sourcepub fn detach_thread(&self, thread_id: ThreadId) -> Result<(), KernelError>
pub fn detach_thread(&self, thread_id: ThreadId) -> Result<(), KernelError>
Detach a thread
Sourcepub fn cancel_thread(&self, thread_id: ThreadId) -> Result<(), KernelError>
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.
Sourcepub fn exit_thread(&self, thread_id: ThreadId, exit_value: *mut u8)
pub fn exit_thread(&self, thread_id: ThreadId, exit_value: *mut u8)
Exit current thread
Sourcepub fn set_thread_priority(
&self,
thread_id: ThreadId,
_priority: ThreadPriority,
) -> Result<(), KernelError>
pub fn set_thread_priority( &self, thread_id: ThreadId, _priority: ThreadPriority, ) -> Result<(), KernelError>
Set thread priority
Sourcepub fn get_thread_priority(
&self,
thread_id: ThreadId,
) -> Result<ThreadPriority, KernelError>
pub fn get_thread_priority( &self, thread_id: ThreadId, ) -> Result<ThreadPriority, KernelError>
Get thread priority
Sourcepub fn set_cpu_affinity(
&self,
thread_id: ThreadId,
cpu_mask: u64,
) -> Result<(), KernelError>
pub fn set_cpu_affinity( &self, thread_id: ThreadId, cpu_mask: u64, ) -> Result<(), KernelError>
Set CPU affinity for thread
Sourcepub fn create_tls_key(
&self,
destructor: Option<fn(*mut u8)>,
) -> Result<TlsKey, KernelError>
pub fn create_tls_key( &self, destructor: Option<fn(*mut u8)>, ) -> Result<TlsKey, KernelError>
Create thread-local storage key
Sourcepub fn delete_tls_key(&self, key: TlsKey) -> Result<(), KernelError>
pub fn delete_tls_key(&self, key: TlsKey) -> Result<(), KernelError>
Delete thread-local storage key
Sourcepub fn set_tls_value(
&self,
thread_id: ThreadId,
key: TlsKey,
value: *mut u8,
) -> Result<(), KernelError>
pub fn set_tls_value( &self, thread_id: ThreadId, key: TlsKey, value: *mut u8, ) -> Result<(), KernelError>
Set thread-local storage value
Sourcepub fn get_tls_value(
&self,
thread_id: ThreadId,
key: TlsKey,
) -> Result<*mut u8, KernelError>
pub fn get_tls_value( &self, thread_id: ThreadId, key: TlsKey, ) -> Result<*mut u8, KernelError>
Get thread-local storage value
Sourcepub fn get_current_thread_id(&self) -> Option<ThreadId>
pub fn get_current_thread_id(&self) -> Option<ThreadId>
Get current thread ID from scheduler
Sourcepub fn list_threads(&self) -> Vec<ThreadId>
pub fn list_threads(&self) -> Vec<ThreadId>
List all threads
Sourcepub fn get_thread_stats(
&self,
thread_id: ThreadId,
) -> Result<ThreadStats, KernelError>
pub fn get_thread_stats( &self, thread_id: ThreadId, ) -> Result<ThreadStats, KernelError>
Get thread statistics