Better some logging

master
WangRunji 7 years ago
parent 9001ac1f3d
commit e3a80a1223

@ -175,7 +175,7 @@ impl InactivePageTable for InactivePageTable0 {
unsafe fn activate(&self) { unsafe fn activate(&self) {
let old_frame = satp::read().frame(); let old_frame = satp::read().frame();
let new_frame = self.p2_frame.clone(); let new_frame = self.p2_frame.clone();
debug!("switch table {:?} -> {:?}", old_frame, new_frame); debug!("switch table {:x?} -> {:x?}", old_frame, new_frame);
if old_frame != new_frame { if old_frame != new_frame {
satp::set(satp::Mode::Sv32, 0, new_frame); satp::set(satp::Mode::Sv32, 0, new_frame);
sfence_vma_all(); sfence_vma_all();
@ -185,13 +185,13 @@ impl InactivePageTable for InactivePageTable0 {
unsafe fn with(&self, f: impl FnOnce()) { unsafe fn with(&self, f: impl FnOnce()) {
let old_frame = satp::read().frame(); let old_frame = satp::read().frame();
let new_frame = self.p2_frame.clone(); let new_frame = self.p2_frame.clone();
debug!("switch table {:?} -> {:?}", old_frame, new_frame); debug!("switch table {:x?} -> {:x?}", old_frame, new_frame);
if old_frame != new_frame { if old_frame != new_frame {
satp::set(satp::Mode::Sv32, 0, new_frame); satp::set(satp::Mode::Sv32, 0, new_frame);
sfence_vma_all(); sfence_vma_all();
} }
f(); f();
debug!("switch table {:?} -> {:?}", new_frame, old_frame); debug!("switch table {:x?} -> {:x?}", new_frame, old_frame);
if old_frame != new_frame { if old_frame != new_frame {
satp::set(satp::Mode::Sv32, 0, old_frame); satp::set(satp::Mode::Sv32, 0, old_frame);
sfence_vma_all(); sfence_vma_all();

@ -14,10 +14,13 @@ lazy_static! {
} }
pub fn alloc_frame() -> Option<usize> { pub fn alloc_frame() -> Option<usize> {
FRAME_ALLOCATOR.lock().alloc().map(|id| id * PAGE_SIZE + MEMORY_OFFSET) let ret = FRAME_ALLOCATOR.lock().alloc().map(|id| id * PAGE_SIZE + MEMORY_OFFSET);
trace!("Allocate frame: {:x?}", ret);
ret
} }
pub fn dealloc_frame(target: usize) { pub fn dealloc_frame(target: usize) {
trace!("Deallocate frame: {:x}", target);
FRAME_ALLOCATOR.lock().dealloc((target - MEMORY_OFFSET) / PAGE_SIZE); FRAME_ALLOCATOR.lock().dealloc((target - MEMORY_OFFSET) / PAGE_SIZE);
} }

@ -131,7 +131,7 @@ impl Processor {
to.status = Status::Running; to.status = Status::Running;
self.scheduler.remove(pid); self.scheduler.remove(pid);
info!("switch from {} to {}\n rsp: ??? -> {:?}", pid0, pid, to.context); info!("switch from {} to {} {:x?}", pid0, pid, to.context);
unsafe { unsafe {
// FIXME: safely pass MutexGuard // FIXME: safely pass MutexGuard
use core::mem::forget; use core::mem::forget;

@ -20,10 +20,11 @@ pub fn current() -> Thread {
/// Puts the current thread to sleep for the specified amount of time. /// Puts the current thread to sleep for the specified amount of time.
pub fn sleep(dur: Duration) { pub fn sleep(dur: Duration) {
info!("sleep: {:?}", dur); let time = dur_to_ticks(dur);
info!("sleep: {:?} ticks", time);
let mut processor = PROCESSOR.try().unwrap().lock(); let mut processor = PROCESSOR.try().unwrap().lock();
let pid = processor.current_pid(); let pid = processor.current_pid();
processor.sleep(pid, dur_to_ticks(dur)); processor.sleep(pid, time);
processor.schedule(); processor.schedule();
fn dur_to_ticks(dur: Duration) -> usize { fn dur_to_ticks(dur: Duration) -> usize {

Loading…
Cancel
Save