by shigemk2

当面は技術的なことしか書かない

ttstart

端末への出力処理を行う

/*
 * Start output on the typewriter. It is used from the top half
 * after some characters have been put on the output queue,
 * from the interrupt routine to transmit the next
 * character, and after a timeout has finished.
 * If the SSTART bit is off for the tty the work is done here,
 * using the protocol of the single-line interfaces (KL, DL, DC);
 * otherwise the address word of the tty structure is
 * taken to be the name of the device-dependent startup routine.
 */
ttstart(atp)
struct tty *atp;
{
    register int *addr, c;
    register struct tty *tp;
    struct { int (*func)(); };

    tp = atp;
    addr = tp->t_addr;
    if (tp->t_state&SSTART) {
        (*addr.func)(tp);
        return;
        }
    /* 端末が送信処理中または送信遅延処理中なら終了 tttcsrは端末インターフェイスの送信ステータスレジスタを操作するために定義された構造体の要素 */
    if ((addr->tttcsr&DONE)==0 || tp->t_state&TIMEOUT)
        return;
    if ((c=getc(&tp->t_outq)) >= 0) {
        /* 文字を出力する処理 */
        if (c<=0177)
            addr->tttbuf = c | (partab[c]&0200);
        /* タイムアウト */
        else {
            timeout(ttrstrt, tp, c&0177);
            tp->t_state =| TIMEOUT;
        }
    }
}
/*
 * Restart typewriter output following a delay
 * timeout.
 * The name of the routine is passed to the timeout
 * subroutine and it is called during a clock interrupt.
 */
ttrstrt(atp)
{
    register struct tty *tp;

    tp = atp;
    tp->t_state =& ~TIMEOUT;
    ttstart(tp);
}

klxint

出力処理が完了したときに発生する割り込みハンドラ

klxint(dev)
{
    register struct tty *tp;

    tp = &kl11[dev.d_minor];
    ttstart(tp);
    if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
        wakeup(&tp->t_outq);
}

まとめ

  • カーネルはテレタイプ端末の処理をサポートする
  • システムのユーザはテレタイプ端末を使ってシステムとやりとりが出来る
  • システムコンソール用の端末が必ず1つ必要
  • 複数のユーザが複数の端末により同時にシステムを使うことが出来る
  • 各端末は3つのバッファキューを持ち、システムと端末間で適切に値を変更してデータをやりとりする