From 82b7092b8a7abceaf9b97234a16a0a67a2561c8d Mon Sep 17 00:00:00 2001 From: wyfcyx Date: Fri, 13 May 2022 06:16:40 +0000 Subject: [PATCH] deploy: 964445e59c475407acfebddd718113bca25e991c --- main/os/task/fn.add_initproc.html | 2 +- .../task/fn.block_current_and_run_next.html | 2 +- main/os/task/fn.block_current_task.html | 2 +- main/os/task/fn.check_signals_of_current.html | 2 +- main/os/task/fn.current_add_signal.html | 2 +- .../os/task/fn.exit_current_and_run_next.html | 2 +- .../task/fn.suspend_current_and_run_next.html | 2 +- main/os/task/index.html | 2 +- main/os/task/struct.INITPROC.html | 8 +++---- main/src/os/task/mod.rs.html | 24 +++++++++++++++++-- 10 files changed, 34 insertions(+), 14 deletions(-) diff --git a/main/os/task/fn.add_initproc.html b/main/os/task/fn.add_initproc.html index 0d2225e8..6f1623e4 100644 --- a/main/os/task/fn.add_initproc.html +++ b/main/os/task/fn.add_initproc.html @@ -4,5 +4,5 @@
-

Function os::task::add_initproc

source · []
pub fn add_initproc()
+

Function os::task::add_initproc

source · []
pub fn add_initproc()
\ No newline at end of file diff --git a/main/os/task/fn.block_current_and_run_next.html b/main/os/task/fn.block_current_and_run_next.html index ef610051..8a799dcc 100644 --- a/main/os/task/fn.block_current_and_run_next.html +++ b/main/os/task/fn.block_current_and_run_next.html @@ -4,5 +4,5 @@
pub fn block_current_and_run_next()
+

Function os::task::block_current_and_run_next

source · []
pub fn block_current_and_run_next()
\ No newline at end of file diff --git a/main/os/task/fn.block_current_task.html b/main/os/task/fn.block_current_task.html index 79191f26..f597b64c 100644 --- a/main/os/task/fn.block_current_task.html +++ b/main/os/task/fn.block_current_task.html @@ -4,6 +4,6 @@
pub fn block_current_task() -> *mut TaskContext
Expand description

This function must be followed by a schedule

+

Function os::task::block_current_task

source · []
pub fn block_current_task() -> *mut TaskContext
Expand description

This function must be followed by a schedule

\ No newline at end of file diff --git a/main/os/task/fn.check_signals_of_current.html b/main/os/task/fn.check_signals_of_current.html index 5034f530..fd45fe2f 100644 --- a/main/os/task/fn.check_signals_of_current.html +++ b/main/os/task/fn.check_signals_of_current.html @@ -4,5 +4,5 @@
pub fn check_signals_of_current() -> Option<(i32, &'static str)>
+

Function os::task::check_signals_of_current

source · []
pub fn check_signals_of_current() -> Option<(i32, &'static str)>
\ No newline at end of file diff --git a/main/os/task/fn.current_add_signal.html b/main/os/task/fn.current_add_signal.html index ad5ca3ce..9b9d856e 100644 --- a/main/os/task/fn.current_add_signal.html +++ b/main/os/task/fn.current_add_signal.html @@ -4,5 +4,5 @@
pub fn current_add_signal(signal: SignalFlags)
+

Function os::task::current_add_signal

source · []
pub fn current_add_signal(signal: SignalFlags)
\ No newline at end of file diff --git a/main/os/task/fn.exit_current_and_run_next.html b/main/os/task/fn.exit_current_and_run_next.html index d9adbdad..b6a60e59 100644 --- a/main/os/task/fn.exit_current_and_run_next.html +++ b/main/os/task/fn.exit_current_and_run_next.html @@ -4,5 +4,5 @@
pub fn exit_current_and_run_next(exit_code: i32)
+

Function os::task::exit_current_and_run_next

source · []
pub fn exit_current_and_run_next(exit_code: i32)
\ No newline at end of file diff --git a/main/os/task/fn.suspend_current_and_run_next.html b/main/os/task/fn.suspend_current_and_run_next.html index fcfd9bd3..c30a3886 100644 --- a/main/os/task/fn.suspend_current_and_run_next.html +++ b/main/os/task/fn.suspend_current_and_run_next.html @@ -4,5 +4,5 @@
pub fn suspend_current_and_run_next()
+

Function os::task::suspend_current_and_run_next

source · []
pub fn suspend_current_and_run_next()
\ No newline at end of file diff --git a/main/os/task/index.html b/main/os/task/index.html index cef9bb33..5a6126ed 100644 --- a/main/os/task/index.html +++ b/main/os/task/index.html @@ -4,7 +4,7 @@
-

Module os::task

source · []

Re-exports

+

Module os::task

source · []

Re-exports

pub use context::TaskContext;
pub use id::kstack_alloc;
pub use id::pid_alloc;
pub use id::KernelStack;
pub use id::PidHandle;
pub use manager::add_task;
pub use manager::pid2process;
pub use manager::remove_from_pid2process;
pub use processor::current_kstack_top;
pub use processor::current_process;
pub use processor::current_task;
pub use processor::current_trap_cx;
pub use processor::current_trap_cx_user_va;
pub use processor::current_user_token;
pub use processor::run_tasks;
pub use processor::schedule;
pub use processor::take_current_task;
pub use signal::SignalFlags;
pub use task::TaskControlBlock;
pub use task::TaskStatus;

Modules

context 🔒
id 🔒
manager 🔒
process 🔒
processor 🔒
signal 🔒
switch 🔒
task 🔒

Structs

Functions

diff --git a/main/os/task/struct.INITPROC.html b/main/os/task/struct.INITPROC.html index 574c99da..44bf6146 100644 --- a/main/os/task/struct.INITPROC.html +++ b/main/os/task/struct.INITPROC.html @@ -4,11 +4,11 @@
-

Struct os::task::INITPROC

source · []
pub struct INITPROC {
+    

Struct os::task::INITPROC

source · []
pub struct INITPROC {
     __private_field: (),
-}

Fields

__private_field: ()

Trait Implementations

The resulting type after dereferencing.

-

Dereferences the value.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}

Fields

__private_field: ()

Trait Implementations

The resulting type after dereferencing.

+

Dereferences the value.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

diff --git a/main/src/os/task/mod.rs.html b/main/src/os/task/mod.rs.html index 7b946d1e..00d18831 100644 --- a/main/src/os/task/mod.rs.html +++ b/main/src/os/task/mod.rs.html @@ -136,6 +136,16 @@ 131 132 133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143
mod context;
 mod id;
 mod manager;
@@ -146,8 +156,9 @@
 #[allow(clippy::module_inception)]
 mod task;
 
+use self::id::TaskUserRes;
 use crate::fs::{open_file, OpenFlags};
-use alloc::sync::Arc;
+use alloc::{sync::Arc, vec::Vec};
 use lazy_static::*;
 use manager::fetch_task;
 use process::ProcessControlBlock;
@@ -228,12 +239,21 @@
         // deallocate user res (including tid/trap_cx/ustack) of all threads
         // it has to be done before we dealloc the whole memory_set
         // otherwise they will be deallocated twice
+        let mut recycle_res = Vec::<TaskUserRes>::new();
         for task in process_inner.tasks.iter().filter(|t| t.is_some()) {
             let task = task.as_ref().unwrap();
             let mut task_inner = task.inner_exclusive_access();
-            task_inner.res = None;
+            if let Some(res) = task_inner.res.take() {
+                recycle_res.push(res);
+            }
         }
+        // dealloc_tid and dealloc_user_res require access to PCB inner, so we
+        // need to collect those user res first, then release process_inner
+        // for now to avoid deadlock/double borrow problem.
+        drop(process_inner);
+        recycle_res.clear();
 
+        let mut process_inner = process.inner_exclusive_access();
         process_inner.children.clear();
         // deallocate other data in user space i.e. program code/data section
         process_inner.memory_set.recycle_data_pages();