1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

solve the deadlock problem & sometimes pass test.

This commit is contained in:
LoremKang 2019-10-22 14:30:23 +08:00
parent 198717c071
commit a180c3b4bb
2 changed files with 7 additions and 7 deletions

View File

@ -5,14 +5,14 @@ use crate::sync::Semaphore;
use spin::RwLock;
use core::cell::UnsafeCell;
pub unsafe trait SemArrTrait {
pub trait SemArrTrait {
//fn new(key: usize, sems: Vec<Semaphore>) -> SemArray;
fn get_x(&self, x: usize) -> &Semaphore;
}
pub struct SemArray {
pub key: usize,
pub sems: UnsafeCell<Vec<Semaphore>>
pub sems: Vec<Semaphore>
}
unsafe impl Sync for SemArray {}
@ -22,15 +22,15 @@ impl SemArray {
pub fn new(key: usize, sems: Vec<Semaphore>) -> SemArray {
SemArray {
key: key,
sems: UnsafeCell::new(sems)
sems: sems
}
}
}
unsafe impl SemArrTrait for SemArray {
fn get_x(&self, x: usize) -> & Semaphore {
impl SemArrTrait for SemArray {
fn get_x(&self, x: usize) -> &Semaphore {
//unsafe { &mut self.sems.get()};
return unsafe {& (*self.sems.get())[x]};
&self.sems[x]
}
}

2
user

@ -1 +1 @@
Subproject commit 10ac61f9ee5f64f2884b54719203be189ecb189d
Subproject commit 11baf01577e0ca87ef88e6f1f95d2192e43e5d58