Separate context and process IDs.

This commit is contained in:
4lDO2
2024-07-08 14:10:31 +02:00
parent 74b824f40f
commit 0da2fce64a
14 changed files with 63 additions and 56 deletions
+10 -7
View File
@@ -131,8 +131,10 @@ impl Eq for WaitpidKey {}
/// A context, which identifies either a process or a thread
#[derive(Debug)]
pub struct Context {
/// The ID of this context
pub id: ContextId,
/// The internal context ID of this context
pub cid: ContextId,
/// The process ID of this context
pub pid: ContextId,
/// The group ID of this context
pub pgid: ContextId,
/// The ID of the parent context
@@ -231,10 +233,11 @@ pub struct SignalState {
}
impl Context {
pub fn new(id: ContextId) -> Result<Context> {
pub fn new(cid: ContextId, pid: ContextId) -> Result<Context> {
let this = Context {
id,
pgid: id,
cid,
pid,
pgid: pid,
ppid: ContextId::from(0),
session_id: ContextId::from(0),
ruid: 0,
@@ -409,7 +412,7 @@ impl Context {
return addr_space;
};
if self.id == super::context_id() {
if self.cid == super::current_cid() {
// TODO: Share more code with context::arch::switch_to.
let this_percpu = PercpuBlock::current();
@@ -449,7 +452,7 @@ impl Context {
}
pub fn caller_ctx(&self) -> CallerCtx {
CallerCtx {
pid: self.id.into(),
pid: self.pid.into(),
uid: self.euid,
gid: self.egid,
}