In the famous "The TTY demystified", the following figure is shown: enter image description here

from which it's seemed that the user process is communicating with the "TTY driver", which in turn communicates with the line disciplie. However, in the O'Reilly book:

enter image description here

It seems that the user application is communicating with the "tty core", which in turn communicate with the line discipline, and the tty driver is the last layer before hardware. Can someone explain what exactly is a "tty driver"? I want to sharpen my question:

As far as I know, drivers are pieces of software used to communicate with hardware. e.g., there's a device driver that knows how to communicate with a disk controller. This driver is the one who actually reads from and writes to the device controller's registers. On the other hand - there are drivers that aren't used to communicate with hardware, such as filesystem drivers, which are basically a software that knows how to organize data in a specific manner.

Which type of driver is a tty driver? And where does the line discipline fit in?


After further reading and observation in the O'Reilly chapter, it seems to me that what O'Reilly means by "TTY Driver" is actually what the "The TTY demystified" means by "UART driver", while what O'Reilly means by "TTY core" is what the "The TTY demystified" means by "TTY driver".

Meaning, the O'Reilly's "TTY driver" is a device driver used to interact with the hardware, whereas the "TTY core" is a kernel-software (hence - driver (?)) used to receive the data from the user process, send it to through the line discipline and to the correct driver (let it be a UART driver or a pty master).

Is that correct?


What is the relation between tty driver and line discipline

The process communicates with the discipline. But the discipline might be raw (a no-op, null discipline), in which case it does nothing more than pass the messages.

That's why the stack in the O'Reilly book has a passthrough on the left and a line discipline on the right. It's their way of explaining that no-op/raw/null line discipline (raw is the actual name, and you can set it with stty raw).

  • Technically stty raw doesn't change the line discipline. It just tunes the tty line discipline to disable all its effects (with the same result as if no line discipline or a no-op line discipline was pushed on top of the serial/pty... device) Jan 18 at 15:13
  • Actually, you'd need stty raw -echo to disable all its effects. Jan 18 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.