Page 1 of 1
Implementing linux type virutal consoles?
Posted: Wed Jul 12, 2006 1:54 pm
by viral
hello..
I have implemented virtual consoles as most of us do.. there are 10 consoles each of them has video buffer & key buffer.. when consoles are switched buffer is swapped.. now this is simple way..
I want to know how Linux/UNIX implement virtual console? tty?? I wanna add remote login facility in my kernel so I think the way linux is doing is something I should check..
How do you implement your virtual consoles?
Re:Implementing linux type virutal consoles?
Posted: Thu Jul 13, 2006 2:31 am
by spix
I want to know how Linux/UNIX implement virtual console? tty?? I wanna add remote login facility in my kernel so I think the way linux is doing is something I should check..
Linux IIRC uses a tty table, when you create a new tty, a new entry is made in that table, which includes function pointers on how to read/write to that tty. Ie it might be console_write, it might be serial_port_write, or some other function.
which tty a task uses is referenced in the task structure, check the single unix specification at the open group's website for detailed info on how to work with ttys.
so, a task wants to print something, it gets it's tty from the tty table and sends it's data to the correct function.
hope that helps..
Re:Implementing linux type virutal consoles?
Posted: Thu Jul 13, 2006 10:54 am
by viral
Thanks for this...
I have some doubts.. Suppose our tty table contains only 4 entry of virtual console.. i.e. points to console_read, console_write.. Now console_read points to same keyboard.. So there should be some way to demultiplex the data read from keyboard and send to key buffers of appropriate consoles.
In my OS, this is done satisfactorily.. But the prob is if there are no. of process(in diff consoles) waiting for inputs from keyboard, Then they are not able to fetch characters from their buffer..
So in short there is some prob with synchronization... Now how you deal with this?
Re:Implementing linux type virutal consoles?
Posted: Thu Jul 13, 2006 2:06 pm
by JoeKayzA
Hi!
You probably don't want to send keyboard events to an application that is not visible, right? Instead, you typically have one tty which is active, and all others are hidden. So, when you receive a character from your keyboard, you have to check which tty is active right now and send that character to the tty's input buffer.
If you meant that there can be multiple processes waiting for input on the _same_ console: Most OSs I know only allow one process per tty to attach to the keyboard input, so there can't be any race conditions.
cheers Joe
Re:Implementing linux type virutal consoles?
Posted: Sun Jul 16, 2006 9:05 am
by viral
Hi..
My console driver is working very nicely on bochs. If multiple shells are running on diff consoles, then each getch() in process blocks it untill keyboard ISR wake up tht process when character is ready in its queue.
Now this method is working perfectly, but on real pc it is quite slow. i.e. after pressing a key, it echo it with some delay as process is first woke up and then it gets executed when it turn arrive (I use round robin).
How you manage this?
Re:Implementing linux type virutal consoles?
Posted: Sun Jul 16, 2006 9:18 am
by bluecode
Viral wrote:Now this method is working perfectly, but on real pc it is quite slow. i.e. after pressing a key, it echo it with some delay as process is first woke up and then it gets executed when it turn arrive (I use round robin).
Just a guess, but perhaps your time slices for each process are to large, so perhaps decreasing them might something you want. This is done be reprogramming the PIT.
btw. if all other proces's are blocking (That means that they are not scheduled, because they are waiting on something), then why isn't your keyboard process scheduled immediatly after the keypress?