Line discipline
Encyclopedia
A line discipline is a layer in the terminal
Computer terminal
A computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system...

 subsystem in some Unix-like
Unix-like
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....

 systems. 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
Pseudo terminal
In some operating systems, including Unix, a pseudo terminal is a pseudo-device pair that provides a text terminal interface without an associated device, such as a virtual console, computer terminal or serial port...

, and the middle line discipline to specify a policy for the driver.

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
Ioctl
In computing, ioctl, short for input/output control, is a system call for device-specific 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...

(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
Unix-like
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....

 system. On input, it handles special characters such as the interrupt character (typically Control-C
Control-C
Control-C is a common computer command. It is generated by pressing the key while holding down the key on a computer keyboard.In graphical user interface environments that use the control key to control the active program, control-C is often used to copy highlighted text to the clipboard...

) and the erase and kill characters (typically backspace
Backspace
Backspace is the keyboard key that originally pushed the typewriter carriage one position backwards, and in modern computer displays moves the cursor one position backwards, deletes the preceding character, and shifts back the text after it by one position....

 or delete
Delete key
The delete key , known less ambiguously as forward delete, performs a function when struck on a computer keyboard during text or command editing, which is to discard the character ahead of the cursor's position, moving all following characters one position "back" towards the freed letterspace. The...

, and Control-U, respectively) and, on output, it replaces all the LF characters with a CR
Carriage return
Carriage return, often shortened to return, refers to a control character or mechanism used to start a new line of text.Originally, the term "carriage return" referred to a mechanism or lever on a typewriter...

/LF sequence.

A serial port could also be used for a dial-up Internet connection
Dial-up access
Dial-up Internet access is a form of Internet access that uses the facilities of the public switched telephone network to establish a dialled connection to an Internet service provider via telephone lines...

 using a serial modem and PPP
Point-to-Point Protocol
In networking, the Point-to-Point Protocol is a data link protocol commonly used in establishing a direct connection between two networking nodes...

. 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.

Some Unix-like
Unix-like
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....

 systems use STREAMS
STREAMS
In computer networking, STREAMS is the native framework in Unix System V for implementing character devices.STREAMS was designed as a modular architecture for implementing full-duplex I/O between kernel or user space processes and device drivers. Its most frequent uses have been in developing...

to implement line disciplines.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK