终端Terminal是什么?
简单来,Terminal就是机器作用终结的地方,机器的边缘,人与机器进行交流的接口。由此,在生活中常见的有三种终端:
常见的终端有哪些?
tty
:/dev/ttyX
代表的都是上述的物理终端,其中,/dev/tty1~/dev/tty6
代表的是本地终端,也就是接到本机的键盘显示器可以操作的终端。比较传统的Unix terminal
如今并不常见,相反X Windows System
变成最常用的接口。以前众多设备都是直接连接到电脑上,现在会通过网络来进行连接。在实际的terminal programming当中,需要结合对应的software terminal emulators。
Terminal I/O has two modes:
在Shell
当中操作stdin和stdout时,默认都是Canonical mode
,以行为单位进行读取和写入。
而对于vim
这样的全屏操作工具,因为需要输入一些单个的控制字符,所以不能以行为单位来操作,所以处于Noncanonical mode
.
每个terminal通常都是由内核当中terminal driver操作,对应的都会有Input queue和Output queue。其次,图中可以看到如果echoing enabled
,那么terminal driver会将Input queue当中的内容copy到Output queue这边,使得可以被Terminal输出。