diff options
author | rsc <rsc> | 2006-09-07 14:12:30 +0000 |
---|---|---|
committer | rsc <rsc> | 2006-09-07 14:12:30 +0000 |
commit | 31085bb4166c18b3dee059160d64b4edd7c5e2f4 (patch) | |
tree | d3b166a2c39f77e06e7104659b537521282f9260 /proc.h | |
parent | 7e019461c8bf0afbe73f959ca3394cce832501fd (diff) | |
download | xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.gz xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.bz2 xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.zip |
more comments
Diffstat (limited to 'proc.h')
-rw-r--r-- | proc.h | 76 |
1 files changed, 40 insertions, 36 deletions
@@ -1,18 +1,19 @@ -// segments in proc->gdt -#define SEG_KCODE 1 // kernel code -#define SEG_KDATA 2 // kernel data+stack +// Segments in proc->gdt +#define SEG_KCODE 1 // kernel code +#define SEG_KDATA 2 // kernel data+stack #define SEG_UCODE 3 #define SEG_UDATA 4 -#define SEG_TSS 5 // this process's task state +#define SEG_TSS 5 // this process's task state #define NSEGS 6 +// Saved registers for kernel context switches. +// Don't need to save all the %fs etc. segment registers, +// because they are constant across kernel contexts. +// Save all the regular registers so we don't need to care +// which are caller save. +// Don't save %eax, because that's the return register. +// The layout of jmpbuf is known to setjmp.S. struct jmpbuf { - // saved registers for kernel context switches - // don't need to save all the fs etc. registers because - // they are constant across kernel contexts - // save all the regular registers so we don't care which are caller save - // don't save eax because that's the return register - // layout known to setjmp.S int ebx; int ecx; int edx; @@ -25,39 +26,42 @@ struct jmpbuf { enum proc_state { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; -struct proc{ - char *mem; // start of process's memory (a kernel address) - // process memory is laid out contiguously: - // text - // original data and bss - // fixed-size stack - // expandable heap - uint sz; // user memory size - char *kstack; // kernel stack - enum proc_state state; - int pid; - int ppid; - void *chan; // sleep - int killed; - struct file *ofile[NOFILE]; - struct inode *cwd; - struct jmpbuf jmpbuf; - struct trapframe *tf; // points into kstack, used to find user regs +// Per-process state +struct proc { + char *mem; // Start of process memory (kernel address) + uint sz; // Size of process memory (bytes) + char *kstack; // Bottom of kernel stack for this process + enum proc_state state; // Process state + int pid; // Process ID + int ppid; // Parent pid + void *chan; // If non-zero, sleeping on chan + int killed; // If non-zero, have been killed + struct file *ofile[NOFILE]; // Open files + struct inode *cwd; // Current directory + struct jmpbuf jmpbuf; // Jump here to run process + struct trapframe *tf; // Trap frame for current interrupt }; +// Process memory is laid out contiguously: +// text +// original data and bss +// fixed-size stack +// expandable heap + extern struct proc proc[]; -extern struct proc *curproc[NCPU]; // can be NULL if no proc running. +extern struct proc *curproc[NCPU]; // Current (running) process per CPU #define MPSTACK 512 +// Per-CPU state struct cpu { - uchar apicid; // Local APIC ID - struct jmpbuf jmpbuf; - struct taskstate ts; // only to give cpu address of kernel stack - struct segdesc gdt[NSEGS]; - char mpstack[MPSTACK]; // per-cpu start-up stack - volatile int booted; - int nlock; // # of locks currently held + uchar apicid; // Local APIC ID + struct jmpbuf jmpbuf; // Jump here to enter scheduler + struct taskstate ts; // Used by x86 to find stack for interrupt + struct segdesc gdt[NSEGS]; // x86 global descriptor table + char mpstack[MPSTACK]; // Per-CPU startup stack + volatile int booted; // Has the CPU started? + int nlock; // Number of locks currently held }; extern struct cpu cpus[NCPU]; |