mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Move Tid from Thread to PosixThread
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
ceb6e2b242
commit
81b0f265b5
@ -2,7 +2,7 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use core::sync::atomic::Ordering;
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use aster_rights::{ReadOp, WriteOp};
|
||||
use ostd::sync::Waker;
|
||||
@ -42,6 +42,8 @@ pub use robust_list::RobustListHead;
|
||||
pub struct PosixThread {
|
||||
// Immutable part
|
||||
process: Weak<Process>,
|
||||
tid: Tid,
|
||||
|
||||
// Mutable part
|
||||
name: Mutex<Option<ThreadName>>,
|
||||
|
||||
@ -87,6 +89,11 @@ impl PosixThread {
|
||||
Weak::clone(&self.process)
|
||||
}
|
||||
|
||||
/// Returns the thread id
|
||||
pub fn tid(&self) -> Tid {
|
||||
self.tid
|
||||
}
|
||||
|
||||
pub fn thread_name(&self) -> &Mutex<Option<ThreadName>> {
|
||||
&self.name
|
||||
}
|
||||
@ -292,3 +299,10 @@ impl PosixThread {
|
||||
self.credentials.dup().restrict()
|
||||
}
|
||||
}
|
||||
|
||||
static POSIX_TID_ALLOCATOR: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
/// Allocates a new tid for the new posix thread
|
||||
pub fn allocate_posix_tid() -> Tid {
|
||||
POSIX_TID_ALLOCATOR.fetch_add(1, Ordering::SeqCst)
|
||||
}
|
||||
|
Reference in New Issue
Block a user