From b6878760c72f73032cf3004d14f0966db0362d69 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Wed, 3 Jan 2018 21:33:56 -0700 Subject: [PATCH] Use seperate stopped status --- src/context/context.rs | 4 +--- src/context/switch.rs | 24 +++++++++++------------- src/scheme/sys/context.rs | 3 +++ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/context/context.rs b/src/context/context.rs index 6ade4693..1ef168f8 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 33956600..e3d0ea7e 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 9e877527..af4e921b 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'); } -- GitLab