打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Terminal

Terminal is a conceptual combination of devices used by humans to interface with the computer. The earliest terminals where text based terminals consisting of a keyboard and a screen connected to the serial port.

Overview
Edit

The following image descibes a typical terminal connected to a Linux system:


If the temrinal is physically remote, a modem could be used to connect it. The software part remains unchanged, the hardware part becomes as follows:

Definitions and Assumptions
Edit

Linux Virtual Terminal
Edit

In Linux, virtual terminal is a character special device file connected to a device driver that in turn controls the terminal. Typically, there are many virtual terminals in a single system /dev/tty1 ~ /dev/tty63 all of which are handled by device driver with major number 4. There are also other character special files related to virtual terminals but handled by the device driver with major number 5. These are /dev/tty which is connected by the kernel to the virtual terminal of the calling process, and /dev/tty1 discussed in (Linux Console) below. The following image shows how each user process's in/out is connected to its respictive virtual terminal.


Linux Psuedo Terminal
Edit

in Linux, a pseudo-terminal, or PTY, is used to create login sessions or provide other capabilities requiring a TTY line discipline (see below), including SLIP or PPP capability, to arbitrary data-generation processes. Each PTY has a master side, named /dev/pty[p-za-e][0-9a-f], and a slave side, named /dev/tty[p-za-e][0-9a-f]. The kernel arbitrates the use of PTYs by allowing each master side to be opened only once. Once the master side has been opened, the corresponding slave device can be used in the same manner as any TTY device. The master and slave devices are connected by the kernel, generating the equivalent of a bidirectional pipe with TTY capabilities. The following image shows how each user process's in/out is connected to the xterm process behind its respective pty:


Linux Console
Edit

Linux console is a pointer file that points to a virtual terminal. Earlier, it used to be a symbolic link, but now it is a character device file handled by device driver with major number 5. Its main objective is to abstract the destination of kernel log messages from the kernel function. This way, printk can send messages only to this file without needing to woory about virtual temrinals or where these messages should be sent (serial port, etc). By default, the “console” is the current virtual terminal. To select a different virtual terminal to receive messages, you can issue ioctl(TIOCLINUX) on any console device. The concole file is /dev/tty1 (previously /dev/console) and is connected by the kernel to one of the virtual terminals during boot e.g “console=tty1”.

Linux Line Discipline
Edit

The line discipline glues the low level device driver code with the high level generic interface routines (such as read(2), write(2) and ioctl(2)), and is responsible for implementing the semantics associated with the device. The policy is separated from the device driver so that the same serial hardware driver can be used by devices that require different data handling. For example, the standard line discipline processes the data it receives from the hardware driver and from applications writing to the device according to the requirements of a terminal on a Unix-like system. On input, it handles special characters such as the interrupt character (typically Control-C) and the erase and kill characters (typically backspace or delete, and Control-U, respectively) and, on output, it replaces all the LF characters with a CR/LF sequence. As another example, a serial port could also be used for a dial-up Internet connection using a serial modem and PPP. In this case, a PPP line discipline would be used; it would accumulate input data from the serial line into PPP input packets, delivering them to the networking stack rather than to the character device, and would transmit packets delivered to it by the networking stack on the serial line.

How-To
Edit

Getting Started
Edit

Pitfalls
Edit

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
usb-serial分析
linux下/dev/tty, /dev/tty0, /dev/console区别
[zhuan]Linux的USB-Serial驱动(从系统初始化到生成tty设备的全过程)
Linux tty,pts
USB 3G网卡驱动流程
[uboot] (番外篇)uboot 驱动模型
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服