next up previous contents
Next: UNIX: System Design Up: 4560 Previous: Java: System Design   Contents

XINU: System Design [264]



Layers:

Written in C and runs on PC, Mac, Sun, LSI-11, etc.



XINU vs. VOS [265]



XINU: Initialization [266]

Initialization is the final step in design



XINU: Processes [267]



XINU: System Calls [268]



XINU: Memory [269]



XINU: Interrupts [270]



XINU: Interrupts [271]



XINU: Real-Time Clock [272]



XINU: Sleeping Processes [273]



XINU: Device I/O [274]

               putc(int descrp, char ch)

               devptr = &devtab[descrp];

               return( (*devptr->dvputc)(devptr,ch) );



Upper-Half TTY Output Device Driver [275]

             ttyputc(devptr, ch)
               struct tty *iptr = &tty[devptr->dvminor];

               wait(iptr->osem);

               iptr->obuff[iptr->ohead++] = ch;
               ++iptr->ocnt;
               if (iptr->ohead >= OBUFLEN) iptr->ohead = 0;

               sendn(iptr->oprocnum,TMSGOK);



Lower-Half TTY Output Device Driver [276]

             PROCESS ttyoproc()

               for (;;) 
                 receive();

               ch = iptr->obuff[iptr->otail++];
               --iptr->ocnt;
               if (iptr->otail >= OBUFLEN) iptr->otail = 0;

               signal(iptr->osem);



XINU: TTY Output Watermarks [277]



XINU: TTY Input Device Drivers [278]

               char ttygetc(devptr)

               PROCESS ttyiproc()



Upper-Half Disk Output Device Driver [279]

               dswrite(devptr, buff, block)

               dskenq(drptr, devptr->dvioblk);

When adding a request for block B to the existing list of requests, schedule it to be performed between requests for i and i+1 if the disk arm will pass over block B on its way from i to i+1. If no such pair i and i+1 exist, add the new request to the end of the list.



             dskenq(drptr, dsptr) {
               if (dsptr->dreqlst == DRNULL) {
                 dsptr->dreqlst = drptr;         /* enqueue */
                 drptr->drnext = DRNULL;
                 sendn(dsptr->dsprocnum); 
               } else OPTIMIZE ALL READS, WRITES, SEEKS }



Lower-Half Disk Device Driver [280]

PROCESS dsinter(dsptr,dsknum) {
  for (;;) {
    drptr = dsptr->dreqlst;
    if (drptr == DRNUILL) receive();  /* if empty, receive */
    dsptr->dreqlst = drptr->drnext;   /* dequeue sequentially */
    switch (drptr->drop) {
      case DREAD: dread(drptr->drbuff,dsknum,drptr->drdba);
                  resume(drptr->drpid); 
                  break;
      case DWRITE:dwrite(drptr->drbuff,dsknum,drptr->drdba);
      case DSYNC, DSEEK, ...
    }
  }
}



Disk Input Device Drivers [281]

              dsread(devptr, buff, block) {
                struct dreq *drptr;
                drptr->drbuff = buff;
                drptr->drdba = block;
                drptr->drop = DREAD;
                drptr->drpid = currpid;
                dskenq(drptr, devptr->dvioblk);
                suspend(currpid);
              }

               dread(drptr->drbuff,dsknum,drptr->drdba);
               resume(drptr->drpid);


next up previous contents
Next: UNIX: System Design Up: 4560 Previous: Java: System Design   Contents
Ted Billard 2001-11-17