Terminal TTY subsystem is the centerpiece of every Linux and UNIX system in general i. Its importance is often overlooked and it is difficult to find a good description suitable for beginners. In today's final part of our series looking at the flow control and configuration options of the terminal driver.
Series Terminals Terminals RSS Revealed malls in dallas Revealed: Past and Present Terminals Revealed: processes and signals Terminals Revealed: flow control and configuration of all episodes
If you run the command in a terminal window yes xterm, you will be in the eyes of a lot of lines with the sign of y. Yes naturally generates command lines with Ypsilon much faster than xterm prosecutes read, update framebuffer X server request to redraw the window and so on. How these two programs can work together?
The answer is called a blocking input / output (blocking malls in dallas I / O). Pseudo is able to maintain only a limited amount of data in its buffer. When the buffer is filled and yes calls the write (2), then the operation of this function is blocked, malls in dallas whereby the process is moved to state yes interruptible sleep. It will not change until the xterm removes any data and the buffer is released. malls in dallas
The same procedure is applied to serial lines. yes able to send data faster than, say, 9600 bits per second, but because the speed of the serial port is limited, the queue in the core will be reached soon, and the next call to write (2) blocks the process or fail with an error code EAGAIN if required nonblocking V / V.
Imagine that communicate with some old VT-100 terminal at 9600 bits per second. Terminal We just sent a complex control sequence by which the screen should be scrolled. At that moment the terminal is fully occupied by scrolling the screen, so it can not receive any data. Physically serial line but still running full speed to 9600 bits per second. In the terminal buffer, but there is not enough space for the characters received. This is a good time to activate the blocking TTY. How to achieve from the terminal?
In previous works, we have already met with the TTY subsystem can give some data bajtům special meaning. By default, malls in dallas such as a ^ C will be passed to the application functions read (2), but instead a group of processes (jobs) to the foreground receives the SIGINT. In the same way, it is possible to configure a TTY to respond to bytes stopping and starting the flow stream. Typically, these characters ^ S (ASCII code 19) and ^ Q (ASCII code 17). Old hardware terminals these bytes and automatically broadcast to expect that on the basis of the operating system restricts the flow of new data. Thus the work flow management, and it's the reason why sometimes xterm seems stuck, press the mistake ^ S.
But there is an important difference: Writing data to a TTY device that is suspended due to flow control, blocking the only process that tries to write while writing to the terminal process of background (if set tostop, ed.) Reasons. malls in dallas Causes sending a signal SIGTTOU entire process group. I do not know why the designers embarked on a UNIX signals SIGTTOU SIGTTIN and when it would be sufficient to rely on blocking I / O. My guess is that the driver is responsible for TTY job control was designed to control the whole job, never a separate process. Setting TTY device
The process can read and change the configuration of the open TTY devices using ioctl (2). API described tty_ioctl (4). This is part of a binary interface between applications and Linux, which remains the same across versions of Linux. Portable malls in dallas applications, however, prefer to make use of POSIX wrappers malls in dallas described in the manual termios (3).
We will not go into the details of the interface termios (3), but if you write a program in C and would like ^ C was served before the advent of SIGINT, banned the editing line or local response, change bitrate or off flow control, everything you need is in this man page.
Let's try it! $ Stty-a speed 38400 baud; 73 rows; 238 columns; line = 0; intr = ^ C; quit = ^ \; erase = ^?; kill = ^ U; eof = ^ D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^ Q; stop = ^ S; susp = ^ Z; rprnt = ^ R; werase malls in dallas = ^ W; lnext = ^ V; flush = ^ O; min = 1; time = 0; -Parenb-parodd cs8-hupcl-cstopb cread-clocal-crtscts-ignbrk brkint malls in dallas ignpar-parmrk-inpck-istrip-inlcr-igncr icrnl ixon-ixoff-iuclc-ixany imaxbel-iutf8 opost-olcuc-ocrnl onlcr-onocr-onlret - ofill-ofdel nl0 cr0 tab0 BS0 vt0 FF0 isig icanon iexten echo echo-echok settings echonl-noflsh-xcase-tostop-echoprt echoctl echoke
The-causing all the settings. Default is to use the control terminal shell in which the tool is run, other equipment can be selected using the-F. Some settings affect UART parameters, some set line discipline and other management tasks. malls in dallas All mixed in a bucket malls in dallas for the Lord. Look at the first line:
speed UART bit rate. Ignored by pseudo. rows, columns driver TTY Someone's idea of the size
No comments:
Post a Comment