Line discipline

Last updated

A line discipline (LDISC) is a layer in the terminal subsystem in some Unix-like systems. [1] The terminal subsystem consists of three layers: the upper layer to provide the character device interface, the lower hardware driver to communicate with the hardware or pseudo terminal, and the middle line discipline to implement behavior common to terminal devices.

Computer terminal computer input/output device; an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system

A computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying or printing data from, a computer or a computing system. The teletype was an example of an early day hardcopy terminal, and predated the use of a computer screen by decades.

Unix-like operating system that behaves in a manner similar to a Unix system

A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-like application is one that behaves like the corresponding Unix command or shell. There is no standard for defining the term, and some difference of opinion is possible as to the degree to which a given operating system or application is "Unix-like".

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. [2] 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.

In computing, ioctl is a system call for device-specific input/output operations and other operations which cannot be expressed by regular system calls. It takes a parameter specifying a request code; the effect of a call depends completely on the request code. Request codes are often device-specific. For instance, a CD-ROM device driver which can instruct a physical device to eject a disc would provide an ioctl request code to do that. Device-independent request codes are sometimes used to give userspace access to kernel functions which are only used by core system software or still under development.

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.

Control-C is a common computer command. It is generated by pressing the C key while holding down the Ctrl key on most computer keyboards.

Backspace keyboard key

Backspace is the keyboard key that originally pushed the typewriter carriage one position backwards, and in modern computer systems moves the display cursor one position backwards, deletes the character at that position, and shifts back the text after that position by one position.

Delete key abbreviated Del on computer keyboards

The delete key is a key on most computer keyboards which typically is used to delete either the character ahead of or beneath the cursor, or the currently-selected object. The key is sometimes referred to as the "forward delete" key. This is because the backspace key also deletes characters, but to the left of the cursor. On many keyboards, such as most Apple keyboards, the key with the backspace function is also labelled "delete".

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.

In computer networking, Point-to-Point Protocol (PPP) is a data link layer communications protocol used to establish a direct connection between two nodes. It connects two routers directly without any host or any other networking device in between. It can provide connection authentication, transmission encryption, and compression.

Some Unix-like systems use STREAMS to implement line disciplines.

In computer networking, STREAMS is the native framework in Unix System V for implementing character device drivers, network protocols, and inter-process communication. In this framework, a stream is a chain of coroutines that pass messages between a program and a device driver. STREAMS originated in Version 8 Research Unix, as Streams.

Related Research Articles

Cygwin Unix subsystem for Windows machines

Cygwin is a POSIX-compatible environment that runs natively on Microsoft Windows. Its goal is to allow programs of Unix-like systems to be recompiled and run natively on Windows with minimal source code modifications by providing them with the same underlying POSIX API they would expect in those systems.

In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer. A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without needing to know precise details about the hardware being used.

Loopback, or loop-back, refers to the routing of electronic signals, digital data streams, or flows of items back to their source without intentional processing or modification. This is primarily a means of testing the communications infrastructure.

A human interface device or HID is a type of computer device usually used by humans that takes input from humans and gives output to humans.

Pseudoterminal

In some operating systems, including Unix, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-devices, one of which, the slave, emulates a hardware text terminal device, the other of which, the master, provides the means by which a terminal emulator process controls the slave.

PHY (chip) abbreviation for the physical layer of the OSI model and refers to the circuitry required to implement physical layer functions

PHY is an abbreviation for the physical layer of the OSI model and refers to the circuitry required to implement physical layer functions.

Networking hardware, also known as network equipment or computer networking devices, are physical devices which are required for communication and interaction between devices on a computer network. Specifically, they mediate data in a computer network. Units which are the last receiver or generate data are called hosts or data terminal equipment.

Architecture of Windows NT

The architecture of Windows NT, a line of operating systems produced and sold by Microsoft, is a layered design that consists of two main components, user mode and kernel mode. It is a preemptive, reentrant operating system, which has been designed to work with uniprocessor and symmetrical multiprocessor (SMP)-based computers. To process input/output (I/O) requests, they use packet-driven I/O, which utilizes I/O request packets (IRPs) and asynchronous I/O. Starting with Windows XP, Microsoft began making 64-bit versions of Windows available; before this, these operating systems only existed in 32-bit versions.

In computer networking, TUN and TAP are virtual network kernel interfaces. Being network devices supported entirely in software, they differ from ordinary network devices which are backed up by hardware network adapters.

A COM port redirector is specialized software that includes the underlying network software necessary to access networked device servers that provide remote serial devices or modems.

A Radio Interface Layer (RIL) is a layer in an operating system which provides an interface to the hardware's radio and modem on e.g. a mobile phone.

In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in MS-DOS, OS/2, and Microsoft Windows. These special files allow an application program to interact with a device by using its device driver via standard input/output system calls. Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions.

Linux console Console of the Linux kernel.

The Linux console is a system console internal to the Linux kernel. The Linux console provides a way for the kernel and other processes to send text output to the user, and to receive text input from the user. The user typically enters text with a computer keyboard and reads the output text on a computer monitor. The Linux kernel supports virtual consoles - consoles that are logically separate, but which access the same physical keyboard and display. The Linux console are implemented by the VT subsystem of the Linux kernel, and do not rely on any user space software. This is in contrast to a terminal emulator, which is a user space process that emulates a terminal, and is typically used in a graphical display environment.

The POSIX terminal interface is the generalized abstraction, comprising both an Application Programming Interface for programs, and a set of behavioural expectations for users of a terminal, as defined by the POSIX standard and the Single Unix Specification. It is a historical development from the terminal interfaces of BSD version 4 and Seventh Edition Unix.

The Seventh Edition Unix terminal interface is the generalized abstraction, comprising both an Application Programming Interface for programs and a set of behavioural expectations for users, of a terminal as historically available in Seventh Edition Unix. It has been largely superseded by the POSIX terminal interface.

devpts

devpts is a virtual filesystem available in the Linux kernel since version 2.1.93. It is normally mounted at /dev/pts and contains solely device files which represent slaves to the multiplexing master located at /dev/ptmx.

References

  1. The TTY demystified
  2. tty(4)    FreeBSD Kernel Interfaces Manual