/DragonOS/kernel/src/libs/ |
H A D | wait_queue.rs | 37 let mut guard: SpinLockGuard<InnerWaitQueue> = self.0.lock_irqsave(); in prepare_to_wait_event() localVariable 45 guard.wait_list.push_back(ProcessManager::current_pcb()); in prepare_to_wait_event() 46 drop(guard); in prepare_to_wait_event() 54 let mut guard: SpinLockGuard<InnerWaitQueue> = self.0.lock_irqsave(); in finish_wait() localVariable 59 guard.wait_list.retain(|x| !Arc::ptr_eq(x, &pcb)); in finish_wait() 60 drop(guard); in finish_wait() 67 let mut guard: SpinLockGuard<InnerWaitQueue> = self.0.lock_irqsave(); in sleep() localVariable 71 guard.wait_list.push_back(ProcessManager::current_pcb()); in sleep() 72 drop(guard); in sleep() 82 let mut guard: SpinLockGuard<InnerWaitQueue> = self.0.lock_irqsave(); in sleep_with_func() localVariable [all …]
|
H A D | rwlock.rs | 159 Some(guard) => return guard, in read() 170 Some(mut guard) => { in read_irqsave() 171 guard.irq_guard = Some(irq_guard); in read_irqsave() 172 return guard; in read_irqsave() 182 if let Some(mut guard) = self.try_read() { in try_read_irqsave() 183 guard.irq_guard = Some(irq_guard); in try_read_irqsave() 184 return Some(guard); in try_read_irqsave() 261 Some(guard) => return guard, in write() 274 Some(mut guard) => { in write_irqsave() 275 guard.irq_guard = Some(irq_guard); in write_irqsave() [all …]
|
H A D | spinlock.rs | 85 if let Ok(guard) = self.try_lock_no_preempt() { in lock_no_preempt() 86 return guard; in lock_no_preempt() 94 if let Ok(guard) = self.try_lock_irqsave() { in lock_irqsave() 95 return guard; in lock_irqsave()
|
/DragonOS/user/apps/user-manage/src/executor/ |
H A D | executor.rs | 103 let mut guard = GLOBAL_FILE.lock().unwrap(); in write_group_file() localVariable 104 let content = read_to_string(&guard.group_file); in write_group_file() 122 guard.group_file.set_len(0).unwrap(); in write_group_file() 123 guard.group_file.seek(std::io::SeekFrom::Start(0)).unwrap(); in write_group_file() 124 guard.group_file.write_all(new_content.as_bytes()).unwrap(); in write_group_file() 125 guard.group_file.flush().unwrap(); in write_group_file() 145 let mut guard = GLOBAL_FILE.lock().unwrap(); in write_gshadow_file() localVariable 146 let content = read_to_string(&guard.gshadow_file); in write_gshadow_file() 163 guard.gshadow_file.set_len(0).unwrap(); in write_gshadow_file() 164 guard in write_gshadow_file() [all …]
|
/DragonOS/kernel/src/process/ |
H A D | syscall.rs | 375 let mut guard = pcb.cred.lock(); in setuid() localVariable 377 if guard.uid.data() == 0 { in setuid() 378 guard.setuid(uid); in setuid() 379 guard.seteuid(uid); in setuid() 380 guard.setsuid(uid); in setuid() 381 } else if uid == guard.uid.data() || uid == guard.suid.data() { in setuid() 382 guard.seteuid(uid); in setuid() 392 let mut guard = pcb.cred.lock(); in setgid() localVariable 394 if guard.egid.data() == 0 { in setgid() 395 guard.setgid(gid); in setgid() [all …]
|
/DragonOS/kernel/src/exception/ |
H A D | ebreak.rs | 17 let guard = KPROBE_MANAGER.lock(); in kprobe_handler() localVariable 18 let kprobe_list = guard.get_break_list(break_addr); in kprobe_handler() 21 let guard = kprobe.read(); in kprobe_handler() localVariable 22 if guard.is_enabled() { in kprobe_handler() 23 guard.call_pre_handler(frame); in kprobe_handler() 32 drop(guard); in kprobe_handler()
|
H A D | debug.rs | 20 let guard = kprobe.read(); in post_kprobe_handler() localVariable 21 if guard.is_enabled() { in post_kprobe_handler() 22 guard.call_post_handler(frame); in post_kprobe_handler() 23 guard.call_event_callback(frame); in post_kprobe_handler()
|
/DragonOS/docs/kernel/locking/ |
H A D | rwlock.md | 16 …wLock的数据结构进行访问和修改. 每个要访问共享数据的会获得一个守卫(guard), 只读进程获得READER(读者守卫),需要修改共享变量的进程获得WRITER(写者守卫),作为RwLock… 132 let guard = LOCK.read(); 133 let value = *guard; 143 let guard = LOCK.read(); 144 let value = *guard; 154 let mut guard = LOCK.write(); 155 *guard += 100; 159 "Writers: the value is {guard} 161 guard = *guard 163 let read_guard=guard.downgrade(); [all …]
|
/DragonOS/kernel/src/mm/ |
H A D | c_adapter.rs | 39 let mut guard = C_ALLOCATION_MAP.lock(); in do_kmalloc() localVariable 40 if unlikely(guard.contains_key(&vaddr)) { in do_kmalloc() 41 drop(guard); in do_kmalloc() 51 guard.insert(vaddr, (vaddr, len, cap)); in do_kmalloc() 61 let mut guard = C_ALLOCATION_MAP.lock(); in kfree() localVariable 62 let p = guard.remove(&vaddr); in kfree() 63 drop(guard); in kfree()
|
H A D | ucontext.rs | 874 let guard = v.lock_irqsave(); in contains() localVariable 875 if guard.region.contains(vaddr) { in contains() 894 let guard = v.lock_irqsave(); in find_nearest() localVariable 895 if guard.region.contains(vaddr) { in find_nearest() 898 if guard.region.start >= vaddr in find_nearest() 900 guard.region.start < nearest.lock_irqsave().region.start in find_nearest() 1138 let mut guard = self.lock_irqsave(); in remap() localVariable 1139 for page in guard.region.pages() { in remap() 1149 guard.flags = flags; in remap() 1156 let mut guard = self.lock_irqsave(); in unmap() localVariable [all …]
|
H A D | fault.rs | 73 let guard = vma.lock_irqsave(); in new() localVariable 74 let file_pgoff = guard.file_page_offset().map(|file_page_offset| { in new() 75 ((address - guard.region().start()) >> MMArch::PAGE_SHIFT) + file_page_offset in new() 129 let mut guard = current_pcb.sched_info().inner_lock_write_irqsave(); in handle_mm_fault() localVariable 130 guard.set_state(ProcessState::Runnable); in handle_mm_fault() 141 let guard = vma.lock_irqsave(); in handle_mm_fault() localVariable 142 let vm_flags = *guard.vm_flags(); in handle_mm_fault() 143 drop(guard); in handle_mm_fault() 242 let guard = vma.lock_irqsave(); in do_anonymous_page() localVariable 245 if let Some(flush) = mapper.map(address, guard.flags()) { in do_anonymous_page()
|
/DragonOS/kernel/src/net/ |
H A D | net_core.rs | 139 let guard: RwLockReadGuard<BTreeMap<usize, Arc<dyn NetDevice>>> = NET_DEVICES.read_irqsave(); in poll_ifaces() localVariable 140 if guard.len() == 0 { in poll_ifaces() 145 for (_, iface) in guard.iter() { in poll_ifaces() 159 let guard: RwLockReadGuard<BTreeMap<usize, Arc<dyn NetDevice>>> = in poll_ifaces_try_lock() localVariable 161 if guard.len() == 0 { in poll_ifaces_try_lock() 174 for (_, iface) in guard.iter() { in poll_ifaces_try_lock() 190 let guard: RwLockReadGuard<BTreeMap<usize, Arc<dyn NetDevice>>> = NET_DEVICES.read_irqsave(); in poll_ifaces_try_lock_onetime() localVariable 191 if guard.len() == 0 { in poll_ifaces_try_lock_onetime() 197 for (_, iface) in guard.iter() { in poll_ifaces_try_lock_onetime()
|
/DragonOS/kernel/src/driver/input/ps2_mouse/ |
H A D | ps_mouse_device.rs | 290 let mut guard = self.inner.lock(); in process_packet() localVariable 291 guard.buf.push(packet); // 更新缓冲区 in process_packet() 292 match guard.current_packet { in process_packet() 298 guard.current_state.flags = flags; in process_packet() 301 let flags = guard.current_state.flags; in process_packet() 303 guard.current_state.x = self.get_x_movement(packet, flags); in process_packet() 307 let flags = guard.current_state.flags; in process_packet() 309 guard.current_state.y = self.get_y_movement(packet, flags); in process_packet() 321 guard.current_packet = (guard.current_packet + 1) % 3; in process_packet() 473 let mut guard = self.inner(); in class() localVariable [all …]
|
H A D | ps_mouse_driver.rs | 103 let guard = self.inner.lock(); in process_packet() localVariable 104 if guard.devices.is_empty() { in process_packet() 108 let device: Option<&Ps2MouseDevice> = guard.devices[0] in process_packet() 136 let mut guard = self.inner.lock(); in add_device() localVariable 138 if guard.devices.iter().any(|dev| Arc::ptr_eq(dev, &device)) { in add_device() 142 guard.devices.push(device); in add_device() 146 let mut guard = self.inner.lock(); in delete_device() localVariable 147 guard.devices.retain(|dev| !Arc::ptr_eq(dev, device)); in delete_device()
|
/DragonOS/kernel/src/filesystem/fat/ |
H A D | fs.rs | 1396 let mut guard: SpinLockGuard<FATInode> = self.0.lock(); in read_at() localVariable 1397 match &guard.inode_type { in read_at() 1400 &guard.fs.upgrade().unwrap(), in read_at() 1404 guard.update_metadata(); in read_at() 1424 let mut guard: SpinLockGuard<FATInode> = self.0.lock(); in write_at() localVariable 1425 let fs: &Arc<FATFileSystem> = &guard.fs.upgrade().unwrap(); in write_at() 1427 match &mut guard.inode_type { in write_at() 1430 guard.update_metadata(); in write_at() 1450 let mut guard: SpinLockGuard<FATInode> = self.0.lock(); in create() localVariable 1451 let fs: &Arc<FATFileSystem> = &guard.fs.upgrade().unwrap(); in create() [all …]
|
/DragonOS/kernel/src/ipc/ |
H A D | pipe.rs | 161 let mut guard = result.inner.lock(); in new() localVariable 162 guard.self_ref = Arc::downgrade(&result); in new() 164 drop(guard); //这一步其实不需要,只要离开作用域,guard生命周期结束,自会解锁 in new() 281 let mut guard = self.inner.lock(); in open() localVariable 287 guard.reader += 1; in open() 290 guard.writer += 1; in open() 314 let mut guard = self.inner.lock(); in close() localVariable 318 assert!(guard.writer > 0); in close() 319 guard.writer -= 1; in close() 321 if guard.writer == 0 { in close() [all …]
|
H A D | signal.rs | 37 let guard = pcb.sig_info_irqsave(); in fatal_signal_pending() localVariable 38 if guard in fatal_signal_pending() 211 let guard = target_pcb.sig_struct(); in complete_signal() localVariable 212 signal_wake_up(target_pcb.clone(), guard, *self == Signal::SIGKILL); in complete_signal() 464 let guard = pcb.sig_struct_irqsave(); in set_current_sig_blocked() localVariable 470 drop(guard); in set_current_sig_blocked()
|
/DragonOS/kernel/src/filesystem/devpts/ |
H A D | mod.rs | 227 let mut guard = self.inner.lock(); in create_with_data() localVariable 229 if guard.children_unchecked_mut().contains_key(name) { in create_with_data() 233 let fs = guard.fs.upgrade().unwrap(); in create_with_data() 249 guard in create_with_data() 259 let guard = self.inner.lock(); in find() localVariable 261 if let Some(dev) = guard.children_unchecked().get(name) { in find() 269 let mut guard = self.inner.lock(); in unlink() localVariable 270 guard.children_unchecked_mut().remove(name); in unlink()
|
/DragonOS/kernel/src/sched/ |
H A D | syscall.rs | 20 let (rq, guard) = rq.self_lock(); in do_sched_yield() 28 drop(guard); in do_sched_yield()
|
/DragonOS/kernel/src/driver/pci/test/ |
H A D | pt_driver.rs | 92 let mut guard = self.driver_data.write(); in add_device() localVariable 94 if guard.devices.iter().any(|dev| Arc::ptr_eq(dev, &device)) { in add_device() 98 guard.devices.push(device); in add_device() 102 let mut guard = self.driver_data.write(); in delete_device() localVariable 103 guard.devices.retain(|dev| !Arc::ptr_eq(dev, device)); in delete_device()
|
/DragonOS/kernel/src/driver/input/serio/i8042/ |
H A D | i8042_driver.rs | 111 let mut guard = self.inner.lock(); in add_device() localVariable 113 if guard.devices.iter().any(|dev| Arc::ptr_eq(dev, &device)) { in add_device() 117 guard.devices.push(device); in add_device() 121 let mut guard = self.inner.lock(); in delete_device() localVariable 122 guard.devices.retain(|dev| !Arc::ptr_eq(dev, device)); in delete_device()
|
/DragonOS/kernel/src/arch/x86_64/mm/ |
H A D | pkru.rs | 19 let guard = vma.lock_irqsave(); in vma_pkey() localVariable 20 ((guard.vm_flags().bits() & PKEY_MASK) >> VM_PKEY_SHIFT) as u16 in vma_pkey()
|
/DragonOS/kernel/src/filesystem/devfs/ |
H A D | mod.rs | 297 let guard: SpinLockGuard<DevFSInode> = self.0.lock(); in add_dir() localVariable 299 if guard.children.contains_key(&DName::from(name)) { in add_dir() 304 guard, in add_dir() 344 mut guard: SpinLockGuard<DevFSInode>, in do_create_with_data() 350 if guard.metadata.file_type != FileType::Dir { in do_create_with_data() 355 if guard.children.contains_key(&name) { in do_create_with_data() 361 parent: guard.self_ref.clone(), in do_create_with_data() 380 fs: guard.fs.clone(), in do_create_with_data() 388 guard.children.insert(name, result.clone()); in do_create_with_data() 418 let guard: SpinLockGuard<DevFSInode> = self.0.lock(); in create_with_data() localVariable [all …]
|
/DragonOS/kernel/src/driver/clocksource/ |
H A D | timer_riscv.rs | 78 let mut guard = SBI_TIMER_INIT_BMP.lock(); in riscv_sbi_timer_init_local() localVariable 80 if guard in riscv_sbi_timer_init_local() 101 guard in riscv_sbi_timer_init_local()
|
/DragonOS/kernel/src/driver/rtc/ |
H A D | rtc_cmos.rs | 86 let mut guard = CMOS_RTC_GENERAL_DEVICE.write(); in probe() localVariable 89 if guard.is_some() { in probe() 94 guard.replace(general_rtc_device.clone()); in probe() 97 drop(guard); in probe()
|