TTY

Operation System

TTY comes from the word teletypes or teletypewriters, means the physical or virtual interrupt. TTY mainly focuses on interactive with user.

In Linux 0.11, there are 3 TTYs, one is for the keyboard typing and screen display and the other 2 ttys are for RS232 serial port input/output. Every TTY has 3 buffering queue, read-queue, write-queue and secondary queue. Here we focus on the keyboard TTY, the RS232 TTY is similar to keyboard TTY. They differences are the input and output device.

When we turn on the computer, the system will add a keyboard ISR in the IDT. While a key has been pressed, the CPU will execute the keyboard ISR. The keyboard ISR will put the code of the key into read-queue. And then, loop over all the data in the read-queue, standardizing the code and putting the standardized code into secondary queue, until the read-queue is empty or the secondary queue is full.

We can not only type letters or numbers but also input some control characters, for example, delete or enter. When we have entered a control character, for example, “delete”, the system will delete the last character in the secondary queue (all the synchronized operations are reflected in the secondary queue). In many cases, the echo flag will be setted. If the echo flag has been setted, the system will also put the standardized code into write-queue, and display the characters on the screen by looping over the write-queue and taking out every character. After the keyboard ISR, the system will wake up the process which is waiting for the TTY.

Post Directory

Directory