mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
xous: replace processes-as-threads with baremetal check
This gets it working on baremetal, and keeps processes-as-threads available for running in hosted mode. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
bd99f33761
commit
49083081c3
5 changed files with 11 additions and 15 deletions
|
|
@ -7,7 +7,7 @@ description = "Core kernel for Xous, including task switching and memory managem
|
|||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
xous = { path = "../xous-rs", features = ["forget-memory-messages", "processes-as-threads"] }
|
||||
xous = { path = "../xous-rs", features = ["forget-memory-messages"] }
|
||||
stats_alloc = { version = "0.1.8", optional = true }
|
||||
sha3 = { default-features = false, version = "0.8.2" }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,6 @@ bitflags = "1.2.1"
|
|||
# will not be implemented. This should only be set by the kernel.
|
||||
forget-memory-messages = []
|
||||
|
||||
# If this is set, create_process() will instead create a thread in
|
||||
# the current process. This is used by the test suite.
|
||||
processes-as-threads = []
|
||||
|
||||
default = []
|
||||
|
||||
[target.'cfg(any(windows,unix))'.dependencies]
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ pub struct ProcessInit {
|
|||
pub key: ProcessKey,
|
||||
}
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub struct ProcessArgsAsThread<F: FnOnce()> {
|
||||
main: F,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
impl<F> ProcessArgsAsThread<F>
|
||||
where
|
||||
F: FnOnce(),
|
||||
|
|
@ -46,12 +46,12 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub struct ProcessHandleAsThread(std::thread::JoinHandle<()>);
|
||||
|
||||
/// If no connection exists, create a new connection to the server. This means
|
||||
/// our parent PID will be PID1. Otherwise, reuse the same connection.
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub fn create_process_pre_as_thread<F>(
|
||||
_args: &ProcessArgsAsThread<F>,
|
||||
) -> core::result::Result<ProcessInit, crate::Error>
|
||||
|
|
@ -70,7 +70,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub fn create_process_post_as_thread<F>(
|
||||
args: ProcessArgsAsThread<F>,
|
||||
init: ProcessInit,
|
||||
|
|
@ -109,7 +109,7 @@ where
|
|||
Ok(ProcessHandleAsThread(thread_main.0))
|
||||
}
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub fn wait_process_as_thread(joiner: ProcessHandleAsThread) -> crate::SysCallResult {
|
||||
joiner.0.join().map(|_| Result::Ok).map_err(|_x| {
|
||||
// panic!("wait error: {:?}", x);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub use definitions::*;
|
|||
pub use messages::*;
|
||||
pub use syscall::*;
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub use arch::ProcessArgsAsThread;
|
||||
|
||||
/// Convert a four-letter string into a 32-bit int.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
// use num_derive::FromPrimitive;
|
||||
// use num_traits::FromPrimitive;
|
||||
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
use crate::ProcessArgsAsThread;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
|
@ -890,7 +890,7 @@ pub fn wait_thread<T>(joiner: crate::arch::WaitHandle<T>) -> SysCallResult {
|
|||
}
|
||||
|
||||
/// Create a new process by running it in its own thread
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub fn create_process_as_thread<F>(
|
||||
args: ProcessArgsAsThread<F>,
|
||||
) -> core::result::Result<crate::arch::ProcessHandleAsThread, Error>
|
||||
|
|
@ -908,7 +908,7 @@ where
|
|||
}
|
||||
|
||||
/// Wait for a thread to finish
|
||||
#[cfg(feature = "processes-as-threads")]
|
||||
#[cfg(not(baremetal))]
|
||||
pub fn wait_process_as_thread(joiner: crate::arch::ProcessHandleAsThread) -> SysCallResult {
|
||||
crate::arch::wait_process_as_thread(joiner)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue