document which proc fields are protected by p->lock

This commit is contained in:
Robert Morris 2019-07-10 09:28:00 -04:00
parent 5eb1685700
commit c0266a877a

View file

@ -87,16 +87,20 @@ enum procstate { UNUSED, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
// Per-process state // Per-process state
struct proc { struct proc {
struct spinlock lock; struct spinlock lock;
// p->lock must be held when using these:
enum procstate state; // Process state
struct proc *parent; // Parent process
void *chan; // If non-zero, sleeping on chan
int killed; // If non-zero, have been killed
int pid; // Process ID
// these are private to the process, so p->lock need not be held.
char *kstack; // Bottom of kernel stack for this process char *kstack; // Bottom of kernel stack for this process
uint64 sz; // Size of process memory (bytes) uint64 sz; // Size of process memory (bytes)
pagetable_t pagetable; // Page table pagetable_t pagetable; // Page table
enum procstate state; // Process state
int pid; // Process ID
struct proc *parent; // Parent process
struct trapframe *tf; // data page for trampoline.S struct trapframe *tf; // data page for trampoline.S
struct context context; // swtch() here to run process struct context context; // swtch() here to run process
void *chan; // If non-zero, sleeping on chan
int killed; // If non-zero, have been killed
struct file *ofile[NOFILE]; // Open files struct file *ofile[NOFILE]; // Open files
struct inode *cwd; // Current directory struct inode *cwd; // Current directory
char name[16]; // Process name (debugging) char name[16]; // Process name (debugging)