code:flushtty - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki

Source

  • 清空 指定tty 的队列
  • 共输入1个参数
    • atp : 指向 指定tty

8250 /* flush all TTY queues

8251  */

8252 flushtty(atp)

8253 struct tty *atp;

8254 {

8255     register struct tty *tp;

8256     register int sps;

8257     tp = atp;

8258     while (getc(&tp->t_canq) >= 0);

  • 清空 非原始输入队列
8259     while (getc(&tp->t_outq) >= 0);
  • 清空 输出队列
8260     wakeup(&tp->t_rawq);

8261     wakeup(&tp->t_outq);

  • 唤醒 等待以下队列的进程
    • 原始输入队列
    • 输出队列
8262     sps = PS->integ;

8263     spl5();

8264     while (getc(&tp->t_rawq) >= 0);

8265     tp->t_delct = 0;

8266     PS->integ = sps;

  • 清空 原始输入队列
  • 清零 定界符数
  • 中断等级提升到5,为了防止 清空过程 中有新的字符进入
8267 }

8268 /* ------------------------- */

Ref

Caller

⚠️ **GitHub.com Fallback** ⚠️