4

The following image represents how a physical terminal (for example: VT100) was connected to a computer running Unix (for example: PDP-11):

enter image description here

Notice the components highlighted in blue, which shows that the terminal is connected to the computer through a serial port (the image says "UART" instead of "serial port"). So basically the terminal has a serial port that is connected though a wire to a serial port on the computer (the image also doesn't show a component for the terminal serial port).

You can change the baud rate for the serial port on the terminal side, also you can change the baud rate for the serial port on the computer side (see here).


Now the following image represents how a virtual terminal is implemented on a modern Linux/Unix machine:

enter image description here

Notice the components highlighted in blue, which shows that the terminal emulator is connected directly to the line discipline without using two "virtual serial ports".

Now my question is: is this image (the virtual terminal implementation) shows the entire components, or should a "virtual serial port" exist after the terminal emulator and another "virtual serial port" should exist before the line discipline?

If these two "virtual serial ports" do exist, can you also change their baud rate also?

I got these two images from here.

10
  • 1
    Your question doesn't make complete sense, and it's rather hard to salvage. "Virtual serial port" is a Windows concept, not a UNIX one. UNIX has line disciplines. Some of these line disciplines do have parameters controlling a speed, a parity, etc., others don't. It's a logical layer that doesn't have to exist if the underlying hardware involved doesn't need it. Oct 31, 2017 at 12:31
  • UARTs are not needed by virtual terminals.
    – fpmurphy
    Oct 31, 2017 at 12:31
  • @Satō Katsura By "virtual serial port" I mean a serial port emulation, just like a terminal emulator is a physical terminal emulation.
    – Joseph
    Oct 31, 2017 at 12:49
  • For a related question with more confusion from block diagrams, see unix.stackexchange.com/questions/367491 .
    – JdeBP
    Oct 31, 2017 at 12:57
  • A UART is involved with things like baud rate, start and stop bits, parity etc. All of these are really just constraints imposed by the physical world, like how fast data can be transmitted over a wire, how to detect where an octet begins and where it ends, error detection, etc. Why would you want to emulate this cumbersome interface, when it really isn't needed? What problem would a "virtual serial port" solve? Oct 31, 2017 at 17:10

2 Answers 2

2

The line discipline controls handling of special characters (like software flow control, or characters generating signals) over the "line" (i.e., electrical wire in early unix systems). There are several possible line disciplines, and the tty driver calls the line discipline responsible for that tty.

So it makes absolutely no sense to have a "virtual serial port" in front of the line discipline. Not in the first picture, and not in the second picture.

The line discipline in turn just calls other parts of the kernel (the serial port driver (USB, UART, whatever), or the emulator for a virtual console, etc.), and also gets called by the corresponding driver if characters arrive. So in some sense this is a "virtual switch" where you can hook in different components.

But there's no pair of serial port drivers that somehow simulate sending a byte as bits over the line with a certain speed, and then reassembling it from bits as a byte. Because that would be unnecessary slow, and doesn't give a functionality.

Nevertheless, you can set the baud rate, amount of stop bits etc. for all tty's. These parameters are just ignored by drivers that don't need them, like the virtual console.

2
  • "So it makes absolutely no sense to have a "virtual serial port" in front of the line discipline. Not in the first picture, and not in the second picture" There is no need to have a "virtual serial port" in front of the line discipline in the first image because there is already a real serial port in front of it (the UART component in the first image is basically a serial port).
    – Joseph
    Nov 1, 2017 at 7:08
  • I meant "in front" = "between the line discipline and the tty driver", using the view from the application down the stack.
    – dirkt
    Nov 1, 2017 at 7:10
-1

Baud rates are defined in /etc/inittab:

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

The baud rate is 38400 in this example.

1
  • However, that's a property of getty not of the terminal emulator. Oct 31, 2017 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .