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;
2424use log:: { Level , LevelFilter , Metadata , Record } ;
2525use spin:: Once ;
2626
27+ use crate :: userland:: scheduler;
2728use crate :: utils:: buffer:: RingBuffer ;
2829use crate :: utils:: sync:: Mutex ;
2930
@@ -71,6 +72,20 @@ impl log::Log for AeroLogger {
7172
7273 serial_print ! ( "\x1b [37;1m{file}:{line} " ) ;
7374
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+
7489 match record. level ( ) {
7590 Level :: Info => serial_print ! ( "\x1b [32;1minfo " ) , // green info
7691 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 {
4444 /// Register the provided task into the task scheduler queue.
4545 fn register_task ( & self , task : Arc < Task > ) ;
4646
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 > > ;
4953
5054 fn init ( & self ) ;
5155 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 {
194194 queue. push_runnable ( task) ;
195195 }
196196
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 ( )
201199 }
202200
203201 fn init ( & self ) {
You can’t perform that action at this time.
0 commit comments