Struct axprocess::Process

source ·
pub struct Process {
Show 13 fields pub parent: AtomicU64, pub children: Mutex<Vec<Arc<Process>>>, pub tasks: Mutex<Vec<AxTaskRef>>, pub fd_manager: FdManager, pub is_zombie: AtomicBool, pub exit_code: AtomicI32, pub memory_set: Mutex<Arc<Mutex<MemorySet>>>, pub heap_bottom: AtomicU64, pub heap_top: AtomicU64, pub signal_modules: Mutex<BTreeMap<u64, SignalModule>>, pub robust_list: Mutex<BTreeMap<u64, FutexRobustList>>, pub blocked_by_vfork: Mutex<bool>, pub file_path: Mutex<String>, /* private fields */
}
Expand description

The process control block

Fields§

§parent: AtomicU64

父进程号

§children: Mutex<Vec<Arc<Process>>>

子进程

§tasks: Mutex<Vec<AxTaskRef>>

所管理的线程

§fd_manager: FdManager

文件描述符管理器

§is_zombie: AtomicBool

进程状态

§exit_code: AtomicI32

退出状态码

§memory_set: Mutex<Arc<Mutex<MemorySet>>>

地址空间

§heap_bottom: AtomicU64

用户堆基址,任何时候堆顶都不能比这个值小,理论上讲是一个常量

§heap_top: AtomicU64

当前用户堆的堆顶,不能小于基址,不能大于基址加堆的最大大小

§signal_modules: Mutex<BTreeMap<u64, SignalModule>>

信号处理模块 第一维代表TaskID,第二维代表对应的信号处理模块

§robust_list: Mutex<BTreeMap<u64, FutexRobustList>>

robust list存储模块 用来存储线程对共享变量的使用地址 具体使用交给了用户空间

§blocked_by_vfork: Mutex<bool>

是否被vfork阻塞

§file_path: Mutex<String>

该进程可执行文件所在的路径

Implementations§

source§

impl Process

source

pub fn pid(&self) -> u64

get the process id

source

pub fn get_parent(&self) -> u64

get the parent process id

source

pub fn set_parent(&self, parent: u64)

set the parent process id

source

pub fn get_exit_code(&self) -> i32

get the exit code of the process

source

pub fn set_exit_code(&self, exit_code: i32)

set the exit code of the process

source

pub fn get_zombie(&self) -> bool

whether the process is a zombie process

source

pub fn set_zombie(&self, status: bool)

set the process as a zombie process

source

pub fn get_heap_top(&self) -> u64

get the heap top of the process

source

pub fn set_heap_top(&self, top: u64)

set the heap top of the process

source

pub fn get_heap_bottom(&self) -> u64

get the heap bottom of the process

source

pub fn set_heap_bottom(&self, bottom: u64)

set the heap bottom of the process

source

pub fn set_vfork_block(&self, value: bool)

set the process as blocked by vfork

source

pub fn set_file_path(&self, path: String)

set the executable file path of the process

source

pub fn get_file_path(&self) -> String

get the executable file path of the process

source

pub fn get_code_if_exit(&self) -> Option<i32>

若进程运行完成,则获取其返回码 若正在运行(可能上锁或没有上锁),则返回None

source§

impl Process

source

pub fn new( pid: u64, parent: u64, memory_set: Mutex<Arc<Mutex<MemorySet>>>, heap_bottom: u64, fd_table: Vec<Option<Arc<dyn FileIO>>> ) -> Self

创建一个新的进程

source

pub fn init(args: Vec<String>, envs: &Vec<String>) -> AxResult<AxTaskRef>

根据给定参数创建一个新的进程,作为应用程序初始进程

source§

impl Process

source

pub fn exec( &self, name: String, args: Vec<String>, envs: &Vec<String> ) -> AxResult<()>

将当前进程替换为指定的用户程序 args为传入的参数 任务的统计时间会被重置

source

pub fn clone_task( &self, flags: CloneFlags, stack: Option<usize>, ptid: usize, tls: usize, ctid: usize, sig_child: bool ) -> AxResult<u64>

实现简易的clone系统调用 返回值为新产生的任务的id

source§

impl Process

与地址空间相关的进程方法

source

pub fn manual_alloc_for_lazy(&self, addr: VirtAddr) -> AxResult<()>

alloc physical memory for lazy allocation manually

source

pub fn manual_alloc_range_for_lazy( &self, start: VirtAddr, end: VirtAddr ) -> AxResult<()>

alloc range physical memory for lazy allocation manually

source

pub fn manual_alloc_type_for_lazy<T: Sized>( &self, obj: *const T ) -> AxResult<()>

alloc physical memory with the given type size for lazy allocation manually

source§

impl Process

与文件相关的进程方法

source

pub fn alloc_fd( &self, fd_table: &mut Vec<Option<Arc<dyn FileIO>>> ) -> AxResult<usize>

为进程分配一个文件描述符

source

pub fn get_cwd(&self) -> String

获取当前进程的工作目录

source§

impl Process

与信号相关的方法

source

pub fn have_signals(&self) -> Option<usize>

查询当前任务是否存在未决信号

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

把当前对象转化为 Any 类型,供后续 downcast 使用
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

供 downcast_mut 使用
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.