P396
KL11のクローズ処理を行う(wflushtty)
klclose(dev) { register struct tty *tp; tp = &kl11[dev.d_minor]; /* 実際の処理 */ wflushtty(tp); /* 状態を保存する */ tp->t_state = 0; }
dmr/tty.c
他の処理をスリープしつつ、キューを空にする
/* * Wait for output to drain, then flush input waiting. */ wflushtty(atp) struct tty *atp; { register struct tty *tp; tp = atp; /* 他の処理を止める */ spl5(); while (tp->t_outq.c_cc) { tp->t_state =| ASLEEP; sleep(&tp->t_outq, TTOPRI); } /* 実際の処理 */ flushtty(tp); spl0(); }
wflushttyの実際の処理
/* * flush all TTY queues */ flushtty(atp) struct tty *atp; { register struct tty *tp; register int sps; tp = atp; while (getc(&tp->t_canq) >= 0); while (getc(&tp->t_outq) >= 0); wakeup(&tp->t_rawq); wakeup(&tp->t_outq); sps = PS->integ; spl5(); while (getc(&tp->t_rawq) >= 0); tp->t_delct = 0; PS->integ = sps; }