proc

Proc

概要

実装

  612: struct Proc
  613: {
  614:         Label  sched;           /* known to l.s */
  615:         char   *kstack;  /* known to l.s */
  616:         Mach   *mach;            /* machine running this proc */
  617:         char   *text;
  618:         char   *user;
  619:         char   *args;
  620:         int    nargs;             /* number of bytes of args */
  621:         Proc   *rnext;           /* next process in run queue */
  622:         Proc   *qnext;           /* next process on queue for a QLock */
  623:         QLock  *qlock;          /* addr of qlock being queued for DEBUG */
  624:         int    state;
  625:         char   *psstate; /* What /proc/#/status reports */
  626:         Segment        *seg[NSEG];
  627:         QLock  seglock; /* locked whenever seg[] changes */
  628:         ulong  pid;
  629:         ulong  noteid;          /* Equivalent of note group */
  630:         Proc   *pidhash; /* next proc in pid hash */
  631: 
  632:         Lock   exl;              /* Lock count and waitq */
  633:         Waitq  *waitq;          /* Exited processes wait children */
  634:         int    nchild;            /* Number of living children */
  635:         int    nwait;             /* Number of uncollected wait records */
  636:         QLock  qwaitr;
  637:         Rendez waitr;          /* Place to hang out in wait */
  638:         Proc   *parent;
  639: 
  640:         Pgrp   *pgrp;            /* Process group for namespace */
  641:         Egrp   *egrp;           /* Environment group */
  642:         Fgrp   *fgrp;            /* File descriptor group */
  643:         Rgrp   *rgrp;            /* Rendez group */
  644: 
  645:         Fgrp   *closingfgrp;     /* used during teardown */
  646: 
  647:         ulong  parentpid;
  648:         ulong  time[6]; /* User, Sys, Real; child U, S, R */
  649: 
  650:         uvlong kentry;         /* Kernel entry time stamp (for profiling) */
  651:         /*
  652:          * pcycles: cycles spent in this process (updated on procsave/restore)
  653:          * when this is the current proc and we're in the kernel
  654:          * (procrestores outnumber procsaves by one)
  655:          * the number of cycles spent in the proc is pcycles + cycles()
  656:          * when this is not the current process or we're in user mode
  657:          * (procrestores and procsaves balance), it is pcycles.
  658:          */
  659:         vlong  pcycles;
  660: 
  661:         int    insyscall;
  662:         int    fpstate;
  663: 
  664:         QLock  debug;           /* to access debugging elements of User */
  665:         Proc   *pdbg;            /* the debugging process */
  666:         ulong  procmode;        /* proc device file mode */
  667:         ulong  privatemem;      /* proc does not let anyone read mem */
  668:         int    hang;              /* hang at next exec for debug */
  669:         int    procctl;   /* Control for /proc debugging */
  670:         ulong  pc;              /* DEBUG only */
  671: 
  672:         Lock   rlock;            /* sync sleep/wakeup with postnote */
  673:         Rendez *r;             /* rendezvous point slept on */
  674:         Rendez sleep;          /* place for syssleep/debug */
  675:         int    notepending;       /* note issued but not acted on */
  676:         int    kp;                /* true if a kernel process */
  677:         Proc   *palarm;  /* Next alarm time */
  678:         ulong  alarm;           /* Time of call */
  679:         int    newtlb;            /* Pager has changed my pte's, I must flush */
  680:         int    noswap;            /* process is not swappable */
  681: 
  682:         uintptr        rendtag;       /* Tag for rendezvous */
  683:         uintptr        rendval;       /* Value for rendezvous */
  684:         Proc   *rendhash;        /* Hash list for tag values */
  685: 
  686:         Timer;                 /* For tsleep and real-time */
  687:         Rendez *trend;
  688:         int    (*tfn)(void*);
  689:         void   (*kpfun)(void*);
  690:         void   *kparg;
  691: 
  692:         FPsave fpsave;         /* address of this is known by db */
  693:         int    scallnr;   /* sys call number - known by db */
  694:         Sargs  s;               /* address of this is known by db */
  695:         int    nerrlab;
  696:         Label  errlab[NERR];
  697:         char   *syserrstr;       /* last error from a system call, errbuf0 or 1 */
  698:         char   *errstr;  /* reason we're unwinding the error stack, errbuf1 or 0 */
  699:         char   errbuf0[ERRMAX];
  700:         char   errbuf1[ERRMAX];
  701:         char   genbuf[128];      /* buffer used e.g. for last name element from namec */
  702:         Chan   *slash;
  703:         Chan   *dot;
  704: 
  705:         Note   note[NNOTE];
  706:         short  nnote;
  707:         short  notified;        /* sysnoted is due */
  708:         Note   lastnote;
  709:         int    (*notify)(void*, char*);
  710: 
  711:         Lock   *lockwait;
  712:         Lock   *lastlock;        /* debugging */
  713:         Lock   *lastilock;       /* debugging */
  714: 
  715:         Mach   *wired;
  716:         Mach   *mp;              /* machine this process last ran on */
  717:         Ref    nlocks;            /* number of locks held by proc */
  718:         ulong  delaysched;
  719:         ulong  priority;        /* priority level */
  720:         ulong  basepri; /* base priority level */
  721:         uchar  fixedpri;        /* priority level deson't change */
  722:         ulong  cpu;             /* cpu average */
  723:         ulong  lastupdate;
  724:         uchar  yield;           /* non-zero if the process just did a sleep(0) */
  725:         ulong  readytime;       /* time process came ready */
  726:         ulong  movetime;        /* last time process switched processors */
  727:         int    preempted; /* true if this process hasn't finished the interrupt
  728:                                  *  that last preempted it
  729:                                  */
  730:         Edf    *edf;              /* if non-null, real-time proc, edf contains scheduling params */
  731:         int    trace;             /* process being traced? */
  732: 
  733:         ulong  qpc;             /* pc calling last blocking qlock */
  734: 
  735:         int    setargs;
  736: 
  737:         void   *ureg;            /* User registers for notes */
  738:         void   *dbgreg;  /* User registers for devproc */
  739:         Notsave;
  740: 
  741:         /*
  742:          *  machine specific MMU
  743:          */
  744:         PMMU;
  745: };