mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
kernel: fix hanging shutdown thread and warnings
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
4130ce7bd1
commit
68691a757d
3 changed files with 20 additions and 23 deletions
|
|
@ -166,11 +166,13 @@ fn listen_thread(
|
|||
|
||||
let pid1_thread = spawn(move || {
|
||||
let mut client = TcpStream::connect(client_addr).expect("couldn't connect to xous server");
|
||||
client.set_nonblocking(true).expect("pid1: couldn't set nonblocking mode");
|
||||
let mut buffer = [0; 32];
|
||||
// println!("KERNEL(1): Started PID1 idle thread");
|
||||
loop {
|
||||
match client.read(&mut buffer) {
|
||||
Ok(0) => return,
|
||||
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => std::thread::sleep(Duration::from_millis(100)),
|
||||
Err(e) => panic!("KERNEL(1): Unable to read buffer: {}", e),
|
||||
Ok(x) => println!("KERNEL(1): Read {} bytes", x),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -718,7 +718,6 @@ impl SystemServices {
|
|||
new_pid: PID,
|
||||
mut new_tid: TID,
|
||||
can_resume: bool,
|
||||
advance_thread: bool,
|
||||
) -> Result<TID, xous::Error> {
|
||||
// println!("Activating PID {}, context {}", new_pid, new_context);
|
||||
let previous_pid = self.current_pid();
|
||||
|
|
@ -859,7 +858,7 @@ impl SystemServices {
|
|||
// }
|
||||
// return Ok(new_tid);
|
||||
// }
|
||||
let new = self.get_process_mut(new_pid)?;
|
||||
let new = self.get_process_mut(new_pid)?;/*
|
||||
new.state = match new.state {
|
||||
ProcessState::Running(x) if (x & 1 << new_tid) == 0 => {
|
||||
return Err(xous::Error::ProcessNotFound)
|
||||
|
|
@ -871,11 +870,11 @@ impl SystemServices {
|
|||
// ProcessState::Running(x | (1 << previous_tid))
|
||||
// }
|
||||
// }
|
||||
other => panic!(
|
||||
other => */panic!(
|
||||
"PID {} invalid process state (not Running): {:?}",
|
||||
previous_pid, other
|
||||
),
|
||||
};
|
||||
previous_pid, new.state
|
||||
)/*,
|
||||
}*/;
|
||||
// if advance_thread {
|
||||
// new.current_thread += 1;
|
||||
// if new.current_thread as TID > arch::process::MAX_CONTEXT {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
|
||||
if blocking && cfg!(baremetal) {
|
||||
// println!("Activating Server context and switching away from Client");
|
||||
ss.activate_process_thread(server_pid, server_tid, !blocking, blocking)
|
||||
ss.activate_process_thread(server_pid, server_tid, !blocking)
|
||||
.map(|_| Ok(xous::Result::Message(envelope)))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
} else if blocking && !cfg!(baremetal) {
|
||||
|
|
@ -166,7 +166,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
let process = ss.get_process(pid).expect("Can't get current process");
|
||||
let ppid = process.ppid;
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
ss.activate_process_thread(ppid, 0, !blocking, blocking)
|
||||
ss.activate_process_thread(ppid, 0, !blocking)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
} else {
|
||||
|
|
@ -293,7 +293,8 @@ fn receive_message(pid: PID, tid: TID, sid: SID) -> SysCallResult {
|
|||
if cfg!(baremetal) {
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
let ppid = ss.get_process(pid).expect("Can't get current process").ppid;
|
||||
ss.activate_process_thread(ppid, 0, false, true)
|
||||
// TODO: Advance thread
|
||||
ss.activate_process_thread(ppid, 0, false)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
}
|
||||
|
|
@ -306,22 +307,14 @@ fn receive_message(pid: PID, tid: TID, sid: SID) -> SysCallResult {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn handle(
|
||||
pid: PID,
|
||||
tid: TID,
|
||||
call: SysCall,
|
||||
) -> SysCallResult {
|
||||
pub fn handle(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
||||
// print!("KERNEL({}:{}): Syscall {:?}", pid, tid, call);
|
||||
let result = handle_inner(pid, tid, call);
|
||||
// println!(" -> {:?}", result);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn handle_inner(
|
||||
pid: PID,
|
||||
tid: TID,
|
||||
call: SysCall,
|
||||
) -> SysCallResult {
|
||||
pub fn handle_inner(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
||||
// let pid = arch::current_pid();
|
||||
|
||||
match call {
|
||||
|
|
@ -454,7 +447,7 @@ pub fn handle_inner(
|
|||
);
|
||||
SWITCHTO_CALLER = Some((pid, tid));
|
||||
}
|
||||
ss.activate_process_thread(new_pid, new_context, true, false)
|
||||
ss.activate_process_thread(new_pid, new_context, true)
|
||||
.map(|_ctx| {
|
||||
// println!("switchto ({}, {})", pid, _ctx);
|
||||
xous::Result::ResumeProcess
|
||||
|
|
@ -476,7 +469,8 @@ pub fn handle_inner(
|
|||
.expect("yielded when no parent context was present")
|
||||
};
|
||||
SystemServices::with_mut(|ss| {
|
||||
ss.activate_process_thread(parent_pid, parent_ctx, true, true)
|
||||
// TODO: Advance thread
|
||||
ss.activate_process_thread(parent_pid, parent_ctx, true)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
})
|
||||
|
|
@ -498,7 +492,8 @@ pub fn handle_inner(
|
|||
let process = ss.get_process(pid).expect("Can't get current process");
|
||||
let ppid = process.ppid;
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
ss.activate_process_thread(ppid, 0, false, true)
|
||||
// TODO: Advance thread
|
||||
ss.activate_process_thread(ppid, 0, false)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
}),
|
||||
|
|
@ -506,7 +501,8 @@ pub fn handle_inner(
|
|||
#[allow(clippy::unit_arg)]
|
||||
ss.create_thread(pid, thread_init).map(|new_tid| {
|
||||
if !cfg!(baremetal) {
|
||||
ss.switch_to_thread(pid, Some(new_tid)).expect("couldn't activate new thread");
|
||||
ss.switch_to_thread(pid, Some(new_tid))
|
||||
.expect("couldn't activate new thread");
|
||||
}
|
||||
xous::Result::ThreadID(new_tid)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue