TTY/PTY details
Posted: Tue Dec 16, 2014 3:11 pm
I think I have a pretty rock solid core for my OS at this point. But I never got around to implementing a proper "terminals". Right now, there is just the console with a little bit of abstraction via the VFS system. Processes can read from "device:///stdin" and write to "device:///stdout" to interact with the console and keyboard and this works great. At least for now, stdin, eventually boils down to a pop from a blocking queue that is filled by the keyboard interrupt. There is no explicit concept of an application being in the foreground so the keystrokes go to the processes on a first come/first serve basis. I want to take things to the next level.
So I want to implement an equivalent to /dev/ptmx and /dev/pts/... But to be honest, I'm simply not familiar enough with how this typically works to know where to start. I've looked in the wiki and it's very abstract and a bit light on details. Is there any relatively easy to grok spec on the APIs that terminals usually offer? Here's my current thoughts.
Assuming we are implementing a traditional 80x25 console. I could start with having a 2000 character buffer that represents the current screen. Writing to the TTY would, in effect, simply update the contents of this buffer and only if that TTY is active would that change be reflected on the screen. (I can imagine some optimizations here, but let's keep it simple). Then I suppose this implies a concept of "which TTY" is active". For a console this seems trivial, I can map the Fn keys to switch around the active one. If I ever get to windowed processes, maybe it's more complex?
What are everyone's thoughts on this? Am I way off track? Or do I have the general concept reasonably on target?
Thanks
So I want to implement an equivalent to /dev/ptmx and /dev/pts/... But to be honest, I'm simply not familiar enough with how this typically works to know where to start. I've looked in the wiki and it's very abstract and a bit light on details. Is there any relatively easy to grok spec on the APIs that terminals usually offer? Here's my current thoughts.
Assuming we are implementing a traditional 80x25 console. I could start with having a 2000 character buffer that represents the current screen. Writing to the TTY would, in effect, simply update the contents of this buffer and only if that TTY is active would that change be reflected on the screen. (I can imagine some optimizations here, but let's keep it simple). Then I suppose this implies a concept of "which TTY" is active". For a console this seems trivial, I can map the Fn keys to switch around the active one. If I ever get to windowed processes, maybe it's more complex?
What are everyone's thoughts on this? Am I way off track? Or do I have the general concept reasonably on target?
Thanks