mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: more renaming context -> thread
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
16d88d8cb5
commit
e1bf9965c3
3 changed files with 23 additions and 23 deletions
|
|
@ -147,7 +147,7 @@ pub struct Server {
|
|||
/// The `context mask` is a bitfield of contexts that are able to handle
|
||||
/// this message. If there are no available contexts, then messages will
|
||||
/// need to be queued.
|
||||
ready_contexts: usize,
|
||||
ready_threads: usize,
|
||||
}
|
||||
|
||||
/// Convert a PID and CTX pair into a `usize` sender
|
||||
|
|
@ -191,7 +191,7 @@ impl Server {
|
|||
queue_head: 0,
|
||||
queue_tail: 0,
|
||||
queue,
|
||||
ready_contexts: 0,
|
||||
ready_threads: 0,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -605,8 +605,8 @@ impl Server {
|
|||
/// Return a context ID that is available and blocking. If no such context
|
||||
/// ID exists, or if this server isn't actually ready to receive packets,
|
||||
/// return None.
|
||||
pub fn take_available_context(&mut self) -> Option<TID> {
|
||||
if self.ready_contexts == 0 {
|
||||
pub fn take_available_thread(&mut self) -> Option<TID> {
|
||||
if self.ready_threads == 0 {
|
||||
return None;
|
||||
}
|
||||
let mut test_ctx_mask = 1;
|
||||
|
|
@ -615,8 +615,8 @@ impl Server {
|
|||
loop {
|
||||
// If the context mask matches this context number, remove it
|
||||
// and return the index.
|
||||
if self.ready_contexts & test_ctx_mask == test_ctx_mask {
|
||||
self.ready_contexts &= !test_ctx_mask;
|
||||
if self.ready_threads & test_ctx_mask == test_ctx_mask {
|
||||
self.ready_threads &= !test_ctx_mask;
|
||||
return Some(ctx_number);
|
||||
}
|
||||
// Advance to the next slot.
|
||||
|
|
@ -635,19 +635,19 @@ impl Server {
|
|||
/// # Panics
|
||||
///
|
||||
/// If the context cannot be returned because it is already blocking.
|
||||
pub fn return_available_context(&mut self, ctx_number: TID) {
|
||||
if self.ready_contexts & 1 << ctx_number != 0 {
|
||||
pub fn return_available_thread(&mut self, tid: TID) {
|
||||
if self.ready_threads & 1 << tid != 0 {
|
||||
panic!(
|
||||
"tried to return context {}, but it was already blocking",
|
||||
ctx_number
|
||||
tid
|
||||
);
|
||||
}
|
||||
self.ready_contexts |= 1 << ctx_number;
|
||||
self.ready_threads |= 1 << tid;
|
||||
}
|
||||
|
||||
/// Add the given context to the list of ready and waiting contexts.
|
||||
pub fn park_context(&mut self, context: TID) {
|
||||
pub fn park_thread(&mut self, tid: TID) {
|
||||
// println!("KERNEL({}): Parking context: {}", self.pid, context);
|
||||
self.ready_contexts |= 1 << context;
|
||||
self.ready_threads |= 1 << tid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ impl SystemServices {
|
|||
|
||||
/// Resume the given process, picking up exactly where it left off. If the
|
||||
/// process is in the Setup state, set it up and then resume.
|
||||
pub fn activate_process_context(
|
||||
pub fn activate_process_thread(
|
||||
&mut self,
|
||||
new_pid: PID,
|
||||
mut new_context: TID,
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
if let Some(ctx_number) = ss
|
||||
.server_from_sidx(sidx)
|
||||
.expect("server couldn't be located")
|
||||
.take_available_context()
|
||||
.take_available_thread()
|
||||
{
|
||||
// println!(
|
||||
// "There are contexts available to handle this message. Marking PID {} as Ready",
|
||||
|
|
@ -115,7 +115,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
.or_else(|e| {
|
||||
ss.server_from_sidx(sidx)
|
||||
.expect("server couldn't be located")
|
||||
.return_available_context(thread);
|
||||
.return_available_thread(thread);
|
||||
Err(e)
|
||||
})?,
|
||||
};
|
||||
|
|
@ -126,13 +126,13 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
ss.ready_context(server_pid, ctx_number).or_else(|e| {
|
||||
ss.server_from_sidx(sidx)
|
||||
.expect("server couldn't be located")
|
||||
.return_available_context(thread);
|
||||
.return_available_thread(thread);
|
||||
Err(e)
|
||||
})?;
|
||||
|
||||
if blocking && cfg!(baremetal) {
|
||||
// println!("Activating Server context and switching away from Client");
|
||||
ss.activate_process_context(server_pid, ctx_number, !blocking, blocking)
|
||||
ss.activate_process_thread(server_pid, ctx_number, !blocking, blocking)
|
||||
.map(|_| Ok(xous::Result::Message(envelope)))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
} else if blocking && !cfg!(baremetal) {
|
||||
|
|
@ -169,7 +169,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_context(ppid, 0, !blocking, blocking)
|
||||
ss.activate_process_thread(ppid, 0, !blocking, blocking)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
}
|
||||
|
|
@ -209,13 +209,13 @@ fn receive_message(pid: PID, tid: TID, sid: SID) -> SysCallResult {
|
|||
// "KERNEL({}): did not have any waiting messages -- parking context {}",
|
||||
// pid, tid
|
||||
// );
|
||||
server.park_context(tid);
|
||||
server.park_thread(tid);
|
||||
|
||||
// For baremetal targets, switch away from this process.
|
||||
if cfg!(baremetal) {
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
let ppid = ss.get_process(pid).expect("Can't get current process").ppid;
|
||||
ss.activate_process_context(ppid, 0, false, true)
|
||||
ss.activate_process_thread(ppid, 0, false, true)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
}
|
||||
|
|
@ -366,7 +366,7 @@ pub fn handle(
|
|||
);
|
||||
SWITCHTO_CALLER = Some((pid, tid));
|
||||
}
|
||||
ss.activate_process_context(new_pid, new_context, true, false)
|
||||
ss.activate_process_thread(new_pid, new_context, true, false)
|
||||
.map(|_ctx| {
|
||||
// println!("switchto ({}, {})", pid, _ctx);
|
||||
xous::Result::ResumeProcess
|
||||
|
|
@ -388,7 +388,7 @@ pub fn handle(
|
|||
.expect("yielded when no parent context was present")
|
||||
};
|
||||
SystemServices::with_mut(|ss| {
|
||||
ss.activate_process_context(parent_pid, parent_ctx, true, true)
|
||||
ss.activate_process_thread(parent_pid, parent_ctx, true, true)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
})
|
||||
|
|
@ -410,7 +410,7 @@ pub fn handle(
|
|||
let process = ss.get_process(pid).expect("Can't get current process");
|
||||
let ppid = process.ppid;
|
||||
unsafe { SWITCHTO_CALLER = None };
|
||||
ss.activate_process_context(ppid, 0, false, true)
|
||||
ss.activate_process_thread(ppid, 0, false, true)
|
||||
.map(|_| Ok(xous::Result::ResumeProcess))
|
||||
.unwrap_or(Err(xous::Error::ProcessNotFound))
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue