Use seperate stopped status

This commit is contained in:
Jeremy Soller
2018-01-03 21:33:56 -07:00
parent c912f42800
commit b6878760c7
3 changed files with 15 additions and 16 deletions

View File

@@ -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,

View File

@@ -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);
}
},
_ => {

View File

@@ -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');
}