structproc { structspinlock lock; // p->lock must be held when using these: enumprocstate state; // Process state void *chan; // If non-zero, sleeping on chan int killed; // If non-zero, have been killed int xstate; // Exit status to be returned to parent's wait int pid; // Process ID
// wait_lock must be held when using this: structproc *parent; // Parent process
// these are private to the process, so p->lock need not be held. uint64 kstack; // Virtual address of kernel stack uint64 sz; // Size of process memory (bytes) pagetable_t pagetable; // User page table structtrapframe *trapframe; // data page for trampoline.S structcontext context; // swtch() here to run process structfile *ofile[NOFILE]; // Open files structinode *cwd; // Current directory char name[16]; // Process name (debugging) structusyscall *usyscallpage; // 共享内存页 };