diff options
| author | Nathaniel Wesley Filardo <nwf@cs.jhu.edu> | 2015-11-07 00:37:23 -0500 | 
|---|---|---|
| committer | Frans Kaashoek <kaashoek@mit.edu> | 2015-11-15 13:28:43 -0500 | 
| commit | 5906118897ef71e21a4868eb33f631eaa22b3800 (patch) | |
| tree | 30048377cec58f71cd67839aec31458c7da75d8a | |
| parent | 02530a4859ce4a629f37dcb6a2773f4b6e4ac71e (diff) | |
| download | xv6-labs-5906118897ef71e21a4868eb33f631eaa22b3800.tar.gz xv6-labs-5906118897ef71e21a4868eb33f631eaa22b3800.tar.bz2 xv6-labs-5906118897ef71e21a4868eb33f631eaa22b3800.zip | |
Remove console input.lock
Use cons.lock for everything.  This eliminates the possibility that two CPUS
independently, simultaneously manipulate the CRTC in cgaputc.
| -rw-r--r-- | console.c | 23 | 
1 files changed, 13 insertions, 10 deletions
| @@ -178,7 +178,6 @@ consputc(int c)  #define INPUT_BUF 128  struct { -  struct spinlock lock;    char buf[INPUT_BUF];    uint r;  // Read index    uint w;  // Write index @@ -190,13 +189,13 @@ struct {  void  consoleintr(int (*getc)(void))  { -  int c; +  int c, dopd = 0; -  acquire(&input.lock); +  acquire(&cons.lock);    while((c = getc()) >= 0){      switch(c){      case C('P'):  // Process listing. -      procdump(); +      dopd = 1;        break;      case C('U'):  // Kill line.        while(input.e != input.w && @@ -224,7 +223,12 @@ consoleintr(int (*getc)(void))        break;      }    } -  release(&input.lock); +  release(&cons.lock); +  // Have to do this without the console lock held. +  if(dopd) { +    dopd = 0; +    procdump(); +  }  }  int @@ -235,15 +239,15 @@ consoleread(struct inode *ip, char *dst, int n)    iunlock(ip);    target = n; -  acquire(&input.lock); +  acquire(&cons.lock);    while(n > 0){      while(input.r == input.w){        if(proc->killed){ -        release(&input.lock); +        release(&cons.lock);          ilock(ip);          return -1;        } -      sleep(&input.r, &input.lock); +      sleep(&input.r, &cons.lock);      }      c = input.buf[input.r++ % INPUT_BUF];      if(c == C('D')){  // EOF @@ -259,7 +263,7 @@ consoleread(struct inode *ip, char *dst, int n)      if(c == '\n')        break;    } -  release(&input.lock); +  release(&cons.lock);    ilock(ip);    return target - n; @@ -284,7 +288,6 @@ void  consoleinit(void)  {    initlock(&cons.lock, "console"); -  initlock(&input.lock, "input");    devsw[CONSOLE].write = consolewrite;    devsw[CONSOLE].read = consoleread; | 
