diff --git a/src/context/context.rs b/src/context/context.rs index 6ade4693e02be11c6f9ffab49e9d7760a3984a5e..1ef168f83004b59313504390b3bbf1168b04803d 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -23,6 +23,7 @@ int_like!(ContextId, AtomicContextId, usize, AtomicUsize); pub enum Status { Runnable, Blocked, + Stopped(usize), Exited(usize) } @@ -51,8 +52,6 @@ pub struct Context { pub status: Status, /// Context running or not pub running: bool, - /// Context is stopped - pub stopped: bool, /// CPU ID, if locked pub cpu_id: Option<usize>, /// Current system call @@ -115,7 +114,6 @@ impl Context { ens: SchemeNamespace::from(0), status: Status::Blocked, running: false, - stopped: false, cpu_id: None, syscall: None, vfork: false, diff --git a/src/context/switch.rs b/src/context/switch.rs index 33956600724f5f91126660f47b8ba621d01446c8..e3d0ea7eb4af375208d7dc7e8acf593b4e60b5f1 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -172,23 +172,21 @@ extern "C" fn signal_handler(sig: usize) { SIGCONT => { println!("Continue"); - let contexts = contexts(); - let context_lock = contexts.current().expect("context::signal_handler not inside of context"); - let mut context = context_lock.write(); - if context.stopped { - context.stopped = false; - context.unblock(); + { + let contexts = contexts(); + let context_lock = contexts.current().expect("context::signal_handler not inside of context"); + let mut context = context_lock.write(); + context.status = Status::Runnable; } }, SIGSTOP | SIGTSTP | SIGTTIN | SIGTTOU => { - println!("Stop"); + println!("Stop {}", sig); - let contexts = contexts(); - let context_lock = contexts.current().expect("context::signal_handler not inside of context"); - let mut context = context_lock.write(); - if ! context.stopped { - context.stopped = true; - context.block(); + { + let contexts = contexts(); + let context_lock = contexts.current().expect("context::signal_handler not inside of context"); + let mut context = context_lock.write(); + context.status = Status::Stopped(sig); } }, _ => { diff --git a/src/scheme/sys/context.rs b/src/scheme/sys/context.rs index 9e877527290ab360f0e8c6111ad75643aa70957d..af4e921b1c8d9d39e0c75351098012a7656af642 100644 --- a/src/scheme/sys/context.rs +++ b/src/scheme/sys/context.rs @@ -39,6 +39,9 @@ pub fn resource() -> Result<Vec<u8>> { } else { stat_string.push('B'); }, + context::Status::Stopped(_sig) => { + stat_string.push('T'); + } context::Status::Exited(_status) => { stat_string.push('Z'); }