AIX is a multiuser operating system that allows user access from local or remote attached device. The communication layer that supports this function is the tty subsystem.
The communication between terminal devices and the programs that read and write to them is controlled by the tty interface. Examples of tty devices are:
This overview provides information about following topics:
The tty subsystem is responsible for:
A controlling terminal manages the input and output operations of a group of processes. The tty special file supports the controlling terminal interface. In practice, user programs seldom open terminal files, such as dev/tty5. These files are opened by a getty or rlogind command and become the user's standard input and output devices.
To perform these tasks, the tty subsystem is composed of modules, or disciplines. A module is a set of processing rules that govern the interface for communication between the computer and an asynchronous device. Modules can be added and removed dynamically for each tty.
The tty subsystem supports three main types of modules:
tty drivers, or hardware disciplines, directly control the hardware (tty devices) or pseudo-hardware (pty devices). They perform the actual input and output to the adapter by providing services to the modules above it: flow control and special semantics when a port is being opened.
The following tty drivers are provided:
cxma | 128-port asynchronous controller High-function terminal. The tty name is /dev/hft/Y, where Y > = 0. |
lft | Low-function terminal. The tty name is /dev/lftY, where Y >= 0. |
lion | 64-port asynchronous controller. |
pty | pseudo-terminal device driver. |
The tty Drivers section provides more information about tty drivers.
Line disciplines provide editing, job control, and special character interpretation. They perform all transformations that occur on the inbound and outbound data stream. Line disciplines also perform most of the error handling and status monitoring for the tty driver.
The following line disciplines are provided:
ldterm | Terminal devices |
sptr | Serial printer (splp command) |
slip | Serial Line Internet Protocol (slattach command) |
Converter modules, or mapping disciplines, translate, or map, input and output characters.
The following converter modules are provided:
nls | National language support for terminal mapping; this converter translates incoming and outgoing characters on the data stream, based on the input and output maps defined for the port (see the setmaps command) |
lc_sjis and uc_sjis | Upper and lower converter used to translate multibyte characters between the Shifted Japanese Industrial Standard (SJIS) and the Advanced Japanese EUC Code (AJEC) handled by the ldterm line discipline. |
The Converter Modules section provides more information about converter modules.
The tty subsystem is based on STREAMS. This STREAMS-based structure provides modularity and flexibility, and enables the following features:
The structure of a tty stream is made up of the following modules:
Unless required, the internationalization modules are not present in the tty stream. The tty Terminal Stream figure shows the tty stream structure for a terminal.
For a serial printer, the internationalization modules are usually not present on the stream; therefore, the structure, shown in the tty Serial Printer Stream figure, is simpler.
The /usr/include/sys/ioctl.h and /usr/include/termios.h files describe the interface to the common services provided by the tty subsystem. The ioctl.h file, which is used by all of the modules, includes the winsize structure, as well as several ioctl commands. The termios.h file includes the POSIX compliant subroutines and data types.
The provided services are grouped and discussed here according to their specific functions.
The following subroutines are provided for hardware control:
cfgetispeed | Gets input baud rate |
cfgetospeed | Gets output baud rate |
cfsetispeed | Sets input baud rate |
cfsetospeed | Sets output baud rate |
tcsendbreak | Sends a break on an asynchronous serial data line |
The following subroutines are provided for flow control:
tcdrain | Waits for output to complete |
tcflow | Performs flow control functions |
tcflush | Discards data from the specified queue |
The following subroutines are provided for terminal information and control:
isatty | Determines if the device is a terminal |
setcsmap | Reads a code set map file and assigns it to the standard input device |
tcgetattr | Gets terminal state |
tcsetattr | Sets terminal state |
ttylock, ttywait, ttyunlock, or ttylocked | Controls tty locking functions |
ttyname | Gets the name of a terminal |
The kernel stores the winsize structure to provide a consistent interface for the current terminal or window size. The winsize structure contains the following fields:
By convention, a value of 0 in all of the winsize structure fields indicates that the structure has not yet been set up.
termdef | Queries terminal characteristics. |
TIOCGWINSZ | Gets the window size. The argument to this ioctl operation is a pointer to a winsize structure, into which the current terminal or window size is placed. |
TIOCSWINSZ | Sets the window size. The argument to this ioctl operation is a pointer to a winsize structure, which is used to set the current terminal or window size information. If the new information differs from the previous, a SIGWINCH signal is sent to the terminal process group. |
The following subroutines are provided for process group management:
tcgetpgrp | Gets foreground process group ID |
tcsetpgrp | Sets foreground process group ID |
The following ioctl operations are used for setting the size of the terminal input and output buffers. The argument to these operations is a pointer to an integer specifying the size of the buffer.
The tty subsystem takes advantage of the synchronization provided by STREAMS. The tty stream modules are configured with the queue pair level synchronization. This synchronization allows the parallelization of the processing for two different streams.
Input and Output Handling Programmer's Overview.
National Language Support Overview for Programming.
Line Discipline Module (ldterm).
Understanding Converter Modules.
The lft special file describes the console device driver.
The termios.h file contains the structures used for the POSIX line discipline.
The termiox.h file contains the interface for asynchronous hardware flow control.
The tty special file is a synonym for the controlling terminal.
The pty Special File describes the pseudo-terminal device driver.