Skip to content

process: Add global ProcessManager and per process fd_manager - #73

Open
liuchuang-vivo wants to merge 5 commits into
vivoblueos:mainfrom
liuchuang-vivo:dev_process
Open

liuchuang-vivo wants to merge 5 commits into
vivoblueos:mainfrom
liuchuang-vivo:dev_process

Conversation

@liuchuang-vivo

@liuchuang-vivo liuchuang-vivo commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

A global ProcessManager to hold Arc refcount. And manage things like pid.
Also adapt the boot and create_thread().

Per process fd_manager records the files opened by each process.

Comment thread kernel/kernel/src/process/mod.rs Outdated
}

pub fn destroy_process(&self, pid: Pid) -> Option<Arc<Process>> {
self.table.remove(pid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the process has child processes, will calling 'destroy_process' cause its child processes to become orphan processes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle orphan processes in the new commits.

pub struct Process {
pid: Pid,
// A weak reference to the parent process.
parent: Weak<Process>,
// The threads owned by this process.
threads: SpinLock<ThreadList>,
// This process's open-file table.
#[cfg(enable_vfs)]
fd_manager: SpinLock<FdManager>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent->child relationship is not recorded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the following commits.


pub fn destroy_process(&self, pid: Pid) -> Option<Arc<Process>> {
self.table.remove(pid)
}

@yyang0814 yyang0814 Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destroy_process does not assert process.has_no_threads() and pid != ROOT_PID before destroy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add ROOT_PID check.
Add ProcessState. When there are threads, the process change to zombie and wait for all threads finished. Then destroy the process.

@liuchuang-vivo
liuchuang-vivo force-pushed the dev_process branch 3 times, most recently from 770245f to ee9b959 Compare October 21, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants