1use hashbrown::HashMap;
4
5use crate::{kernel::WaitQueue, sync::SpinLock};
6
7lazy_static::lazy_static! {
8 pub static ref FUTEX_MANAGER: SpinLock<FutexManager> = SpinLock::new(FutexManager::new());
10}
11
12pub struct FutexManager {
14 futexes: HashMap<usize, WaitQueue>,
15}
16
17impl FutexManager {
18 pub fn new() -> Self {
20 Self {
21 futexes: HashMap::new(),
22 }
23 }
24
25 pub fn get_wait_queue(&mut self, uaddr: usize) -> &mut WaitQueue {
27 self.futexes.entry(uaddr).or_insert_with(WaitQueue::new)
28 }
29}