root/proc.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 // Per-CPU state
   2 struct cpu {
   3   uchar apicid;                // Local APIC ID
   4   struct context *scheduler;   // swtch() here to enter scheduler
   5   struct taskstate ts;         // Used by x86 to find stack for interrupt
   6   struct segdesc gdt[NSEGS];   // x86 global descriptor table
   7   volatile uint started;       // Has the CPU started?
   8   int ncli;                    // Depth of pushcli nesting.
   9   int intena;                  // Were interrupts enabled before pushcli?
  10   struct proc *proc;           // The process running on this cpu or null
  11 };
  12 
  13 extern struct cpu cpus[NCPU];
  14 extern int ncpu;
  15 
  16 //PAGEBREAK: 17
  17 // Saved registers for kernel context switches.
  18 // Don't need to save all the segment registers (%cs, etc),
  19 // because they are constant across kernel contexts.
  20 // Don't need to save %eax, %ecx, %edx, because the
  21 // x86 convention is that the caller has saved them.
  22 // Contexts are stored at the bottom of the stack they
  23 // describe; the stack pointer is the address of the context.
  24 // The layout of the context matches the layout of the stack in swtch.S
  25 // at the "Switch stacks" comment. Switch doesn't save eip explicitly,
  26 // but it is on the stack and allocproc() manipulates it.
  27 struct context {
  28   uint edi;
  29   uint esi;
  30   uint ebx;
  31   uint ebp;
  32   uint eip;
  33 };
  34 
  35 enum procstate { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
  36 
  37 // Per-process state
  38 struct proc {
  39   uint sz;                     // Size of process memory (bytes)
  40   pde_t* pgdir;                // Page table
  41   char *kstack;                // Bottom of kernel stack for this process
  42   enum procstate state;        // Process state
  43   int pid;                     // Process ID
  44   struct proc *parent;         // Parent process
  45   struct trapframe *tf;        // Trap frame for current syscall
  46   struct context *context;     // swtch() here to run process
  47   void *chan;                  // If non-zero, sleeping on chan
  48   int killed;                  // If non-zero, have been killed
  49   struct file *ofile[NOFILE];  // Open files
  50   struct inode *cwd;           // Current directory
  51   char name[16];               // Process name (debugging)
  52 };
  53 
  54 // Process memory is laid out contiguously, low addresses first:
  55 //   text
  56 //   original data and bss
  57 //   fixed-size stack
  58 //   expandable heap

/* [previous][next][first][last][top][bottom][index][help]  */