Added missing current_thread assignment in test_lock_multiple
This commit is contained in:
parent
7b7d48c775
commit
d35314bead
@ -391,6 +391,7 @@ impl ThreadManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// self.get_obj_addrs().update_lock(id, lock);
|
// self.get_obj_addrs().update_lock(id, lock);
|
||||||
|
|
||||||
machine.interrupt.set_status(old_status);
|
machine.interrupt.set_status(old_status);
|
||||||
Ok(MachineOk::Ok)
|
Ok(MachineOk::Ok)
|
||||||
}
|
}
|
||||||
@ -495,35 +496,36 @@ mod test {
|
|||||||
let lock_id = thread_manager.get_obj_addrs().add_lock(lock);
|
let lock_id = thread_manager.get_obj_addrs().add_lock(lock);
|
||||||
let thread_1 = Rc::new(RefCell::new(Thread::new("test_lock_1")));
|
let thread_1 = Rc::new(RefCell::new(Thread::new("test_lock_1")));
|
||||||
let thread_2 = Rc::new(RefCell::new(Thread::new("test_lock_2")));
|
let thread_2 = Rc::new(RefCell::new(Thread::new("test_lock_2")));
|
||||||
let thread_test_1 = thread_1.clone();
|
thread_manager.ready_to_run(thread_1.clone());
|
||||||
let thread_test_2 = thread_2.clone();
|
thread_manager.ready_to_run(thread_2.clone());
|
||||||
thread_manager.ready_to_run(Rc::clone(&thread_1));
|
thread_manager.set_g_current_thread(Some(thread_1.clone()));
|
||||||
thread_manager.ready_to_run(Rc::clone(&thread_2));
|
|
||||||
thread_manager.set_g_current_thread(Some(thread_1));
|
|
||||||
|
|
||||||
thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error at first iteration: ");
|
thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error at first iteration: ");
|
||||||
{
|
{
|
||||||
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
||||||
assert_eq!(lock.owner,Some(thread_test_1.clone()));
|
assert_eq!(lock.owner,Some(thread_1.clone()));
|
||||||
assert!(!lock.free);
|
assert!(!lock.free);
|
||||||
assert!(lock.waiting_queue.is_empty());
|
assert!(lock.waiting_queue.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_manager.set_g_current_thread(Some(thread_2));
|
thread_manager.set_g_current_thread(Some(thread_2.clone()));
|
||||||
thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error at second iteration: ");
|
thread_manager.lock_acquire(lock_id, &mut machine).expect("lock acquire return an error at second iteration: ");
|
||||||
{
|
{
|
||||||
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
||||||
assert_eq!(lock.owner,Some(thread_test_1));
|
assert_eq!(lock.owner,Some(thread_1.clone()));
|
||||||
assert!(!lock.free);
|
assert!(!lock.free);
|
||||||
assert_eq!(lock.waiting_queue.iter().count(),1);
|
assert_eq!(lock.waiting_queue.iter().count(),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error at first iteration: ");
|
thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error at first iteration: ");
|
||||||
{
|
{
|
||||||
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
||||||
assert_eq!(lock.owner, Some(thread_test_2));
|
assert_eq!(lock.owner, Some(thread_2.clone()));
|
||||||
assert!(!lock.free);
|
assert!(!lock.free);
|
||||||
assert!(lock.waiting_queue.is_empty());
|
assert!(lock.waiting_queue.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_manager.set_g_current_thread(Some(thread_2.clone()));
|
||||||
thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error at second iteration: ");
|
thread_manager.lock_release(lock_id, &mut machine).expect("lock release return an error at second iteration: ");
|
||||||
{
|
{
|
||||||
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
let lock = thread_manager.get_obj_addrs().search_lock(lock_id).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user