code:ttstart - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 启动 tty 输出
- 输入1个参数 atp
- atp : 指定 tty
8495 /* Start output on the typewriter. It is used from the top
8496 * half after some characters have been put on the output
8497 * queue, from the interrupt routine to transmit the next
8498 * character, and after a timeout has finished.
8499 * If the SSTART bit is off for the tty the work is done
8500 * here, using the protocol of the single-line interfaces
8501 * (kl, dl, dc); otherwise the address word of the tty
8502 * structure is taken to be the name of the device-dependent
8503 * start-up routine.
8504 */
8505 ttstart(atp)
8506 struct tty *atp;
8507 {
8508 register int *addr, c;
8509 register struct tty *tp;
8510 struct { int (*func)(); };
8511
8512 tp = atp;
8513 addr = tp->t_addr;
8514 if (tp->t_state&SSTART) {
8515 (*addr.func)(tp);
8516 return;
8517 }
8518 if ((addr->tttcsr&DONE)==0 || tp->t_state&TIMEOUT)
- 若 tty 有特殊启动函数,调用函数,并返回
8519 return;
8520 if ((c=getc(&tp->t_outq)) >= 0) {
- 接收器 作业未完成 或 TIMEOUT标志被置(参看后面的说明),函数返回
8521 if (c<=0177)
8522 addr->tttbuf = c | (partab[c]&0200);
8523 else {
8524 timeout(ttrstrt, tp, c&0177);
8525 tp->t_state =| TIMEOUT;
8526 }
8527 }
8528 }该标志用于保证ttstart两次连续的调用,第二次再不调用ttrstrt,避免嵌套调用
- tty 输出队列不为空,则取出头元素c
8529 /* ------------------------- */