mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
rename contexts -> threads and spawn -> create
This ensures we're more consistent in naming for these constructs. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
ba7bb29ce2
commit
1216963d24
4 changed files with 50 additions and 26 deletions
|
|
@ -239,7 +239,7 @@ pub fn handle(pid: PID, call: SysCall) -> core::result::Result<xous::Result, xou
|
||||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||||
}),
|
}),
|
||||||
SysCall::SpawnThread(entrypoint, stack_pointer, argument) => {
|
SysCall::CreateThread(entrypoint, stack_pointer, argument) => {
|
||||||
SystemServices::with_mut(|ss| {
|
SystemServices::with_mut(|ss| {
|
||||||
ss.spawn_thread(entrypoint, stack_pointer, argument)
|
ss.spawn_thread(entrypoint, stack_pointer, argument)
|
||||||
.map(xous::Result::ThreadID)
|
.map(xous::Result::ThreadID)
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ fn send_borrow_message() {
|
||||||
// let s = String::from_utf8_lossy(&bt);
|
// let s = String::from_utf8_lossy(&bt);
|
||||||
// println!("SERVER: Got message: {:?} -> \"{}\"", bt, s);
|
// println!("SERVER: Got message: {:?} -> \"{}\"", bt, s);
|
||||||
xous::return_memory(envelope.sender, m.buf).unwrap();
|
xous::return_memory(envelope.sender, m.buf).unwrap();
|
||||||
// println!("SERVER: Returned memory");
|
// println!("SERVER: Returned memory");
|
||||||
} else {
|
} else {
|
||||||
panic!("unexpected message type");
|
panic!("unexpected message type");
|
||||||
}
|
}
|
||||||
|
|
@ -378,7 +378,8 @@ fn measure_memory_usage() {
|
||||||
// Run the "shutdown" test in its own thread. This ensures that
|
// Run the "shutdown" test in its own thread. This ensures that
|
||||||
// any TLS is freed when the thread exits.
|
// any TLS is freed when the thread exits.
|
||||||
let jh = as_process(|| shutdown());
|
let jh = as_process(|| shutdown());
|
||||||
jh.join().expect("couldn't run shutdown test for measuring memory");
|
jh.join()
|
||||||
|
.expect("couldn't run shutdown test for measuring memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_in_use(start: &Stats) -> usize {
|
fn memory_in_use(start: &Stats) -> usize {
|
||||||
|
|
@ -395,16 +396,39 @@ fn measure_memory_usage() {
|
||||||
println!("After test: {:#?} ({} bytes in use)", after_join, miu);
|
println!("After test: {:#?} ({} bytes in use)", after_join, miu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn multiple_contexts() {
|
fn multiple_contexts() {
|
||||||
// // Start the kernel in its own thread
|
// Start the kernel in its own thread
|
||||||
// let (main_thread, server_spec) = start_kernel(SERVER_SPEC);
|
let main_thread = start_kernel(SERVER_SPEC);
|
||||||
|
|
||||||
// let (server_addr_send, server_addr_recv) = channel();
|
let internal_server = as_process(|| {
|
||||||
// xous::create_server(name)
|
let server = xous::create_server(0x53_4534).expect("couldn't create server");
|
||||||
|
let connection = xous::connect(server).expect("couldn't connect to our own server");
|
||||||
|
|
||||||
// // Any process ought to be able to shut down the system currently.
|
xous::send_message(
|
||||||
// rsyscall(SysCall::Shutdown).expect("unable to shutdown server");
|
connection,
|
||||||
|
xous::Message::Scalar(xous::ScalarMessage {
|
||||||
|
id: 1,
|
||||||
|
arg1: 2,
|
||||||
|
arg2: 3,
|
||||||
|
arg3: 4,
|
||||||
|
arg4: 5,
|
||||||
|
}),
|
||||||
|
).expect("couldn't send message");
|
||||||
|
|
||||||
// main_thread.join().expect("couldn't join kernel process");
|
let msg = xous::receive_message(server).expect("couldn't receive message");
|
||||||
// }
|
println!("Received message: {:?}", msg);
|
||||||
|
// let client_thread = xous::create_thread(move || {
|
||||||
|
|
||||||
|
// })
|
||||||
|
});
|
||||||
|
|
||||||
|
internal_server
|
||||||
|
.join()
|
||||||
|
.expect("couldn't join internal_server process");
|
||||||
|
|
||||||
|
// Any process ought to be able to shut down the system currently.
|
||||||
|
rsyscall(SysCall::Shutdown).expect("unable to shutdown server");
|
||||||
|
|
||||||
|
main_thread.join().expect("couldn't join kernel process");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ pub enum Result {
|
||||||
Error(Error),
|
Error(Error),
|
||||||
MemoryAddress(MemoryAddress),
|
MemoryAddress(MemoryAddress),
|
||||||
MemoryRange(MemoryRange),
|
MemoryRange(MemoryRange),
|
||||||
ReadyContexts(
|
ReadyThreads(
|
||||||
usize, /* count */
|
usize, /* count */
|
||||||
usize,
|
usize,
|
||||||
/* pid0 */ usize, /* context0 */
|
/* pid0 */ usize, /* context0 */
|
||||||
|
|
@ -386,7 +386,7 @@ impl Result {
|
||||||
Result::Error(e) => [1, e.to_usize(), 0, 0, 0, 0, 0, 0],
|
Result::Error(e) => [1, e.to_usize(), 0, 0, 0, 0, 0, 0],
|
||||||
Result::MemoryAddress(s) => [2, s.get(), 0, 0, 0, 0, 0, 0],
|
Result::MemoryAddress(s) => [2, s.get(), 0, 0, 0, 0, 0, 0],
|
||||||
Result::MemoryRange(r) => [3, r.addr.get(), r.size.get(), 0, 0, 0, 0, 0],
|
Result::MemoryRange(r) => [3, r.addr.get(), r.size.get(), 0, 0, 0, 0, 0],
|
||||||
Result::ReadyContexts(count, pid0, ctx0, pid1, ctx1, pid2, ctx2) => {
|
Result::ReadyThreads(count, pid0, ctx0, pid1, ctx1, pid2, ctx2) => {
|
||||||
[4, *count, *pid0, *ctx0, *pid1, *ctx1, *pid2, *ctx2]
|
[4, *count, *pid0, *ctx0, *pid1, *ctx1, *pid2, *ctx2]
|
||||||
}
|
}
|
||||||
Result::ResumeProcess => [5, 0, 0, 0, 0, 0, 0, 0],
|
Result::ResumeProcess => [5, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
|
@ -426,7 +426,7 @@ impl Result {
|
||||||
|
|
||||||
Result::MemoryRange(MemoryRange { addr, size })
|
Result::MemoryRange(MemoryRange { addr, size })
|
||||||
}
|
}
|
||||||
4 => Result::ReadyContexts(src[1], src[2], src[3], src[4], src[5], src[6], src[7]),
|
4 => Result::ReadyThreads(src[1], src[2], src[3], src[4], src[5], src[6], src[7]),
|
||||||
5 => Result::ResumeProcess,
|
5 => Result::ResumeProcess,
|
||||||
6 => Result::ServerID((src[1], src[2], src[3], src[4])),
|
6 => Result::ServerID((src[1], src[2], src[3], src[4])),
|
||||||
7 => Result::ConnectionID(src[1] as CID),
|
7 => Result::ConnectionID(src[1] as CID),
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ pub enum SysCall {
|
||||||
SwitchTo(PID, usize /* context ID */),
|
SwitchTo(PID, usize /* context ID */),
|
||||||
|
|
||||||
/// Get a list of contexts that can be run in the given PID.
|
/// Get a list of contexts that can be run in the given PID.
|
||||||
ReadyContexts(PID),
|
ReadyThreads(PID),
|
||||||
|
|
||||||
/// Create a new Server
|
/// Create a new Server
|
||||||
///
|
///
|
||||||
|
|
@ -239,7 +239,7 @@ pub enum SysCall {
|
||||||
ReturnMemory(MessageSender, MemoryRange),
|
ReturnMemory(MessageSender, MemoryRange),
|
||||||
|
|
||||||
/// Spawn a new thread
|
/// Spawn a new thread
|
||||||
SpawnThread(
|
CreateThread(
|
||||||
MemoryAddress, /* entrypoint */
|
MemoryAddress, /* entrypoint */
|
||||||
MemoryAddress, /* stack pointer */
|
MemoryAddress, /* stack pointer */
|
||||||
Option<MemoryAddress>, /* argument */
|
Option<MemoryAddress>, /* argument */
|
||||||
|
|
@ -268,7 +268,7 @@ enum SysCallNumber {
|
||||||
ClaimInterrupt = 5,
|
ClaimInterrupt = 5,
|
||||||
FreeInterrupt = 6,
|
FreeInterrupt = 6,
|
||||||
SwitchTo = 7,
|
SwitchTo = 7,
|
||||||
ReadyContexts = 8,
|
ReadyThreads = 8,
|
||||||
WaitEvent = 9,
|
WaitEvent = 9,
|
||||||
IncreaseHeap = 10,
|
IncreaseHeap = 10,
|
||||||
DecreaseHeap = 11,
|
DecreaseHeap = 11,
|
||||||
|
|
@ -278,7 +278,7 @@ enum SysCallNumber {
|
||||||
ReceiveMessage = 15,
|
ReceiveMessage = 15,
|
||||||
SendMessage = 16,
|
SendMessage = 16,
|
||||||
Connect = 17,
|
Connect = 17,
|
||||||
SpawnThread = 18,
|
CreateThread = 18,
|
||||||
UnmapMemory = 19,
|
UnmapMemory = 19,
|
||||||
ReturnMemory = 20,
|
ReturnMemory = 20,
|
||||||
CreateProcess = 21,
|
CreateProcess = 21,
|
||||||
|
|
@ -362,8 +362,8 @@ impl SysCall {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
SysCall::ReadyContexts(a1) => [
|
SysCall::ReadyThreads(a1) => [
|
||||||
SysCallNumber::ReadyContexts as usize,
|
SysCallNumber::ReadyThreads as usize,
|
||||||
a1.get() as usize,
|
a1.get() as usize,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|
@ -478,8 +478,8 @@ impl SysCall {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
SysCall::SpawnThread(a1, a2, a3) => [
|
SysCall::CreateThread(a1, a2, a3) => [
|
||||||
SysCallNumber::SpawnThread as usize,
|
SysCallNumber::CreateThread as usize,
|
||||||
a1.get(),
|
a1.get(),
|
||||||
a2.get(),
|
a2.get(),
|
||||||
a3.map(|x| x.get()).unwrap_or_default(),
|
a3.map(|x| x.get()).unwrap_or_default(),
|
||||||
|
|
@ -548,7 +548,7 @@ impl SysCall {
|
||||||
),
|
),
|
||||||
Some(SysCallNumber::FreeInterrupt) => SysCall::FreeInterrupt(a1),
|
Some(SysCallNumber::FreeInterrupt) => SysCall::FreeInterrupt(a1),
|
||||||
Some(SysCallNumber::SwitchTo) => SysCall::SwitchTo(pid_from_usize(a1)?, a2 as usize),
|
Some(SysCallNumber::SwitchTo) => SysCall::SwitchTo(pid_from_usize(a1)?, a2 as usize),
|
||||||
Some(SysCallNumber::ReadyContexts) => SysCall::ReadyContexts(pid_from_usize(a1)?),
|
Some(SysCallNumber::ReadyThreads) => SysCall::ReadyThreads(pid_from_usize(a1)?),
|
||||||
Some(SysCallNumber::IncreaseHeap) => SysCall::IncreaseHeap(
|
Some(SysCallNumber::IncreaseHeap) => SysCall::IncreaseHeap(
|
||||||
a1 as usize,
|
a1 as usize,
|
||||||
MemoryFlags::from_bits(a2).ok_or(Error::InvalidSyscall)?,
|
MemoryFlags::from_bits(a2).ok_or(Error::InvalidSyscall)?,
|
||||||
|
|
@ -610,7 +610,7 @@ impl SysCall {
|
||||||
Some(SysCallNumber::ReturnMemory) => {
|
Some(SysCallNumber::ReturnMemory) => {
|
||||||
SysCall::ReturnMemory(a1, MemoryRange::new(a2, a3))
|
SysCall::ReturnMemory(a1, MemoryRange::new(a2, a3))
|
||||||
}
|
}
|
||||||
Some(SysCallNumber::SpawnThread) => SysCall::SpawnThread(
|
Some(SysCallNumber::CreateThread) => SysCall::CreateThread(
|
||||||
MemoryAddress::new(a1).ok_or(Error::InvalidSyscall)?,
|
MemoryAddress::new(a1).ok_or(Error::InvalidSyscall)?,
|
||||||
MemoryAddress::new(a2).ok_or(Error::InvalidSyscall)?,
|
MemoryAddress::new(a2).ok_or(Error::InvalidSyscall)?,
|
||||||
MemoryAddress::new(a3),
|
MemoryAddress::new(a3),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue