@@ -18,7 +18,7 @@ use axerrno::{AxError, AxResult};
1818use axmm:: AddrSpace ;
1919use axpoll:: PollSet ;
2020use axsync:: { Mutex , spin:: SpinNoIrq } ;
21- use axtask:: { AxTaskRef , TaskExt , TaskInner , WeakAxTaskRef , current} ;
21+ use axtask:: { AxCpuMask , AxTaskRef , TaskExt , TaskInner , WeakAxTaskRef , current} ;
2222use extern_trait:: extern_trait;
2323use hashbrown:: HashMap ;
2424use lazy_static:: lazy_static;
@@ -147,12 +147,18 @@ unsafe impl TaskExt for Box<Thread> {
147147 let scope = self . proc_data . scope . read ( ) ;
148148 unsafe { ActiveScope :: set ( & scope) } ;
149149 core:: mem:: forget ( scope) ;
150+ let mut on_cpu_mask = self . proc_data . on_cpu_mask . write ( ) ;
151+ on_cpu_mask. set ( axhal:: percpu:: this_cpu_id ( ) , true ) ;
150152 }
151153
152154 fn on_leave ( & self ) {
153155 ActiveScope :: set_global ( ) ;
154156 unsafe { self . proc_data . scope . force_read_decrement ( ) } ;
155157 }
158+
159+ fn on_cpu_mask ( & self ) -> AxCpuMask {
160+ self . proc_data . on_cpu_mask . read ( ) . clone ( )
161+ }
156162}
157163
158164/// Helper trait to access the thread from a task.
@@ -184,6 +190,8 @@ pub struct ProcessData {
184190 /// The virtual memory address space.
185191 // TODO: scopify
186192 pub aspace : Arc < Mutex < AddrSpace > > ,
193+ /// The CPUs on which the task has run.
194+ pub on_cpu_mask : RwLock < AxCpuMask > ,
187195 /// The resource scope
188196 pub scope : RwLock < Scope > ,
189197 /// The user heap bottom
@@ -226,6 +234,7 @@ impl ProcessData {
226234 exe_path : RwLock :: new ( exe_path) ,
227235 cmdline : RwLock :: new ( cmdline) ,
228236 aspace,
237+ on_cpu_mask : RwLock :: new ( AxCpuMask :: new ( ) ) ,
229238 scope : RwLock :: new ( Scope :: new ( ) ) ,
230239 heap_bottom : AtomicUsize :: new ( crate :: config:: USER_HEAP_BASE ) ,
231240 heap_top : AtomicUsize :: new ( crate :: config:: USER_HEAP_BASE ) ,
0 commit comments