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.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Joseph
  • 375
  • 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. – Satō Katsura Oct 31 '17 at 12:31
  • UARTs are not needed by virtual terminals. – fpmurphy Oct 31 '17 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 '17 at 12:49
  • For a related question with more confusion from block diagrams, see https://unix.stackexchange.com/questions/367491/ . – JdeBP Oct 31 '17 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? – Johan Myréen Oct 31 '17 at 17:10
  • @Johan Myréen "Why would you want to emulate this cumbersome interface, when it really isn't needed? What problem would a "virtual serial port" solve?" You are probably correct, but maybe some programs depended on a certain baud rate to run, and so when they moved from physical implementation to virtual implementation, they also decided to emulate the serial ports to make sure those programs would still be able to run. – Joseph Nov 01 '17 at 04:30
  • As I said: Windows has "virtual serial ports" as a logical layer. It added it in order to allow dialup programs written for DOS to run in a multi-tasking environment. The equivalent logical layer for UNIX are line disciplines. – Satō Katsura Nov 01 '17 at 05:51
  • @Satō Katsura "The equivalent logical layer for UNIX are line disciplines" I don't think that the line discipline can be called "equivalent" to the serial port, since the line discipline existed in the physical implementation also. – Joseph Nov 01 '17 at 06:13
  • Line disciplines are the equivalent logical layer. Then again, you seem to have a solution and you're looking for a problem, rather than the other way around. Over and out for me. – Satō Katsura Nov 01 '17 at 06:18
  • @Satō Katsura You use the term "logical layer" but you don't define what you mean by it. – Joseph Nov 01 '17 at 06:26

2 Answers2

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.

dirkt
  • 32,309
  • "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 01 '17 at 07:08
  • I meant "in front" = "between the line discipline and the tty driver", using the view from the application down the stack. – dirkt Nov 01 '17 at 07: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.

Ipor Sircer
  • 14,546
  • 1
  • 27
  • 39