xref: /DragonOS/kernel/src/process/pid.rs (revision 9358ff0f6f7daa18d6fab4497de025736b3d6725)
1 use crate::{include::bindings::bindings::pt_regs, arch::asm::current::current_pcb};
2 
3 #[allow(dead_code)]
4 #[derive(Debug, Clone, Copy)]
5 #[repr(u8)]
6 pub enum PidType {
7     /// pid类型是进程id
8     PID = 1,
9     TGID = 2,
10     PGID = 3,
11     SID = 4,
12     MAX = 5,
13 }
14 
15 /// 为PidType实现判断相等的trait
16 impl PartialEq for PidType {
17     fn eq(&self, other: &PidType) -> bool {
18         *self as u8 == *other as u8
19     }
20 }
21 
22 /**
23  * @brief 获取当前进程的pid
24  */
25 #[no_mangle]
26 pub extern "C" fn sys_getpid(_regs: &pt_regs)->u64{
27     return current_pcb().pid as u64;
28 }