File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ use alloc::string::String;
24
24
use log:: { Level , LevelFilter , Metadata , Record } ;
25
25
use spin:: Once ;
26
26
27
+ use crate :: userland:: scheduler;
27
28
use crate :: utils:: buffer:: RingBuffer ;
28
29
use crate :: utils:: sync:: Mutex ;
29
30
@@ -71,6 +72,20 @@ impl log::Log for AeroLogger {
71
72
72
73
serial_print ! ( "\x1b [37;1m{file}:{line} " ) ;
73
74
75
+ if scheduler:: is_initialized ( ) {
76
+ // fetch the current task, grab the TID and PID.
77
+ scheduler:: get_scheduler ( )
78
+ . inner
79
+ . current_task_optional ( )
80
+ . map ( |task| {
81
+ serial_print ! (
82
+ "(tid={}, pid={}) " ,
83
+ task. tid( ) . as_usize( ) ,
84
+ task. pid( ) . as_usize( )
85
+ ) ;
86
+ } ) ;
87
+ }
88
+
74
89
match record. level ( ) {
75
90
Level :: Info => serial_print ! ( "\x1b [32;1minfo " ) , // green info
76
91
Level :: Warn => serial_print ! ( "\x1b [33;1mwarn " ) , // yellow warn
Original file line number Diff line number Diff line change @@ -44,8 +44,12 @@ pub trait SchedulerInterface: Send + Sync + Downcastable {
44
44
/// Register the provided task into the task scheduler queue.
45
45
fn register_task ( & self , task : Arc < Task > ) ;
46
46
47
- /// Get a reference-counting pointer to the current task.
48
- fn current_task ( & self ) -> Arc < Task > ;
47
+ fn current_task ( & self ) -> Arc < Task > {
48
+ self . current_task_optional ( )
49
+ . expect ( "current_task: current task not found" )
50
+ }
51
+
52
+ fn current_task_optional ( & self ) -> Option < Arc < Task > > ;
49
53
50
54
fn init ( & self ) ;
51
55
fn wake_up ( & self , task : Arc < Task > ) ;
Original file line number Diff line number Diff line change @@ -194,10 +194,8 @@ impl SchedulerInterface for RoundRobin {
194
194
queue. push_runnable ( task) ;
195
195
}
196
196
197
- fn current_task ( & self ) -> Arc < Task > {
198
- let queue = self . queue . get ( ) ;
199
-
200
- queue. current_task . as_ref ( ) . unwrap ( ) . clone ( )
197
+ fn current_task_optional ( & self ) -> Option < Arc < Task > > {
198
+ self . queue . get ( ) . current_task . as_ref ( ) . cloned ( )
201
199
}
202
200
203
201
fn init ( & self ) {
You can’t perform that action at this time.
0 commit comments