Implement mpsc using semaphores.
This commit is contained in:
parent
9bc1e8d2e9
commit
45c33f2ce2
8 changed files with 187 additions and 2 deletions
|
@ -4,7 +4,7 @@ use crate::mm::{
|
|||
translated_refmut,
|
||||
};
|
||||
use crate::trap::{TrapContext, trap_handler};
|
||||
use crate::sync::{UPSafeCell, Mutex};
|
||||
use crate::sync::{UPSafeCell, Mutex, Semaphore};
|
||||
use core::cell::RefMut;
|
||||
use super::id::RecycleAllocator;
|
||||
use super::TaskControlBlock;
|
||||
|
@ -33,6 +33,7 @@ pub struct ProcessControlBlockInner {
|
|||
pub tasks: Vec<Option<Arc<TaskControlBlock>>>,
|
||||
pub task_res_allocator: RecycleAllocator,
|
||||
pub mutex_list: Vec<Option<Arc<dyn Mutex>>>,
|
||||
pub semaphore_list: Vec<Option<Arc<Semaphore>>>,
|
||||
}
|
||||
|
||||
impl ProcessControlBlockInner {
|
||||
|
@ -97,6 +98,7 @@ impl ProcessControlBlock {
|
|||
tasks: Vec::new(),
|
||||
task_res_allocator: RecycleAllocator::new(),
|
||||
mutex_list: Vec::new(),
|
||||
semaphore_list: Vec::new(),
|
||||
})}
|
||||
});
|
||||
// create a main thread, we should allocate ustack and trap_cx here
|
||||
|
@ -210,6 +212,7 @@ impl ProcessControlBlock {
|
|||
tasks: Vec::new(),
|
||||
task_res_allocator: RecycleAllocator::new(),
|
||||
mutex_list: Vec::new(),
|
||||
semaphore_list: Vec::new(),
|
||||
})}
|
||||
});
|
||||
// add child
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue