11#[ cfg( feature = "tls" ) ]
22use crate :: tls:: TlsArea ;
33
4- use crate :: { TaskStack , TimeStat , arch:: TaskContext } ;
54extern crate alloc;
5+ use crate :: { TaskStack , TimeStat , arch:: TaskContext } ;
66use alloc:: { boxed:: Box , string:: String } ;
7-
8- #[ allow( unused_imports) ]
97use core:: {
108 cell:: UnsafeCell ,
119 fmt,
12- sync:: atomic:: { AtomicBool , AtomicI32 , AtomicU8 , AtomicU64 , AtomicUsize , Ordering } ,
10+ sync:: atomic:: { AtomicBool , AtomicI32 , AtomicUsize , Ordering } ,
1311} ;
1412use memory_addr:: { VirtAddr , align_up_4k} ;
1513
1614/// A unique identifier for a thread.
1715#[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
18- pub struct TaskId ( u64 ) ;
16+ pub struct TaskId ( usize ) ;
1917pub const MAX_RT_PRIO : usize = 99 ;
2018
21- static ID_COUNTER : AtomicU64 = AtomicU64 :: new ( 1 ) ;
19+ static ID_COUNTER : AtomicUsize = AtomicUsize :: new ( 1 ) ;
2220impl TaskId {
2321 /// Create a new task ID.
2422 pub fn new ( ) -> Self {
@@ -27,7 +25,7 @@ impl TaskId {
2725
2826 /// Convert the task ID to a `u64`.
2927 pub const fn as_u64 ( & self ) -> u64 {
30- self . 0
28+ self . 0 as u64
3129 }
3230
3331 #[ cfg( feature = "monolithic" ) ]
@@ -152,7 +150,7 @@ pub struct TaskInner {
152150 ctx : UnsafeCell < TaskContext > ,
153151
154152 #[ cfg( feature = "monolithic" ) ]
155- process_id : AtomicU64 ,
153+ process_id : AtomicUsize ,
156154
157155 #[ cfg( feature = "monolithic" ) ]
158156 /// 是否是所属进程下的主线程
@@ -166,20 +164,20 @@ pub struct TaskInner {
166164 pub page_table_token : UnsafeCell < usize > ,
167165
168166 #[ cfg( feature = "monolithic" ) ]
169- set_child_tid : AtomicU64 ,
167+ set_child_tid : AtomicUsize ,
170168
171169 #[ cfg( feature = "monolithic" ) ]
172- clear_child_tid : AtomicU64 ,
170+ clear_child_tid : AtomicUsize ,
173171
174172 /// 时间统计, 无论是否为宏内核架构都可能被使用到
175173 #[ allow( unused) ]
176174 time : UnsafeCell < TimeStat > ,
177175
178- #[ cfg( feature = "monolithic" ) ]
179176 /// TODO: to support the sched_setaffinity
180177 ///
181178 /// TODO: move to the upper layer
182- pub cpu_set : AtomicU64 ,
179+ #[ cfg( feature = "monolithic" ) ]
180+ pub cpu_set : AtomicUsize ,
183181
184182 #[ cfg( feature = "monolithic" ) ]
185183 /// The scheduler status of the task, which defines the scheduling policy and priority
@@ -258,7 +256,7 @@ impl TaskInner {
258256
259257 t. entry = Some ( Box :: into_raw ( Box :: new ( entry) ) ) ;
260258
261- t. process_id . store ( process_id, Ordering :: Release ) ;
259+ t. process_id . store ( process_id as _ , Ordering :: Release ) ;
262260
263261 t. page_table_token = UnsafeCell :: new ( page_table_token) ;
264262
@@ -398,17 +396,17 @@ impl TaskInner {
398396impl TaskInner {
399397 /// store the child thread ID at the location pointed to by child_tid in clone args
400398 pub fn set_child_tid ( & self , tid : usize ) {
401- self . set_child_tid . store ( tid as u64 , Ordering :: Release )
399+ self . set_child_tid . store ( tid, Ordering :: Release )
402400 }
403401
404402 /// clear (zero) the child thread ID at the location pointed to by child_tid in clone args
405403 pub fn set_clear_child_tid ( & self , tid : usize ) {
406- self . clear_child_tid . store ( tid as u64 , Ordering :: Release )
404+ self . clear_child_tid . store ( tid, Ordering :: Release )
407405 }
408406
409407 /// get the pointer to the child thread ID
410408 pub fn get_clear_child_tid ( & self ) -> usize {
411- self . clear_child_tid . load ( Ordering :: Acquire ) as usize
409+ self . clear_child_tid . load ( Ordering :: Acquire )
412410 }
413411
414412 #[ inline]
@@ -428,13 +426,13 @@ impl TaskInner {
428426 #[ inline]
429427 /// get the process ID of the task
430428 pub fn get_process_id ( & self ) -> u64 {
431- self . process_id . load ( Ordering :: Acquire )
429+ self . process_id . load ( Ordering :: Acquire ) as _
432430 }
433431
434432 #[ inline]
435433 /// set the process ID of the task
436434 pub fn set_process_id ( & self , process_id : u64 ) {
437- self . process_id . store ( process_id, Ordering :: Release ) ;
435+ self . process_id . store ( process_id as _ , Ordering :: Release ) ;
438436 }
439437
440438 // /// 获取内核栈的第一个trap上下文
@@ -464,12 +462,12 @@ impl TaskInner {
464462 set_size * 4
465463 } ;
466464 let now_mask = mask & 1 << ( ( len) - 1 ) ;
467- self . cpu_set . store ( now_mask as u64 , Ordering :: Release )
465+ self . cpu_set . store ( now_mask as _ , Ordering :: Release )
468466 }
469467
470468 /// to get the CPU set
471469 pub fn get_cpu_set ( & self ) -> usize {
472- self . cpu_set . load ( Ordering :: Acquire ) as usize
470+ self . cpu_set . load ( Ordering :: Acquire )
473471 }
474472
475473 /// set the scheduling policy and priority
@@ -533,7 +531,7 @@ impl TaskInner {
533531 time : UnsafeCell :: new ( TimeStat :: new ( ) ) ,
534532
535533 #[ cfg( feature = "monolithic" ) ]
536- process_id : AtomicU64 :: new ( 0 ) ,
534+ process_id : AtomicUsize :: new ( 0 ) ,
537535
538536 #[ cfg( feature = "monolithic" ) ]
539537 is_leader : AtomicBool :: new ( false ) ,
@@ -542,14 +540,14 @@ impl TaskInner {
542540 page_table_token : UnsafeCell :: new ( 0 ) ,
543541
544542 #[ cfg( feature = "monolithic" ) ]
545- set_child_tid : AtomicU64 :: new ( 0 ) ,
543+ set_child_tid : AtomicUsize :: new ( 0 ) ,
546544
547545 #[ cfg( feature = "monolithic" ) ]
548- clear_child_tid : AtomicU64 :: new ( 0 ) ,
546+ clear_child_tid : AtomicUsize :: new ( 0 ) ,
549547
550548 #[ cfg( feature = "monolithic" ) ]
551549 // 一开始默认都可以运行在每个CPU上
552- cpu_set : AtomicU64 :: new ( 0 ) ,
550+ cpu_set : AtomicUsize :: new ( 0 ) ,
553551
554552 #[ cfg( feature = "monolithic" ) ]
555553 sched_status : UnsafeCell :: new ( SchedStatus {
0 commit comments