I'm currently studying for a computer science exam, and I've come across a concept that has me somewhat stumped.
When one types a key on the keyboard, an ASCII character is transmitted to the CPU. Upon reception of this character, the CPU outputs the same character to the screen. This process is called echoing. Instead of having the CPU involved, why don't we simply have this echoing process done within the keyboard/screen unit so that the CPU is free to do other useful work?
Now, intuitively, I feel like this is because there is no defined keyboard/screen unit, and the CPU is the device which is responsible for communicating between the screen and the keyboard, through the interconnection network. However, I feel like the fact that a keyboard/screen unit is mentioned may mean I'm missing an important concept. Is this the case? Why do we involve the CPU in the echo process?
Asked By : MMMMMCK
Answered By : Kyle Jones
Letting the computer see each character as it is typed allows programmers to make the user interface more dynamic.
Back when a serious computer was the size of several upright refrigerators and computers operated on user input a line at a time, terminal input was handled as you described. You typed a line of text on a terminal which displayed it locally (often on paper). Only when you pressed the ENTER or RETURN key was the text sent to the mainframe or minicomputer to be processed.
But even back then, the advantage of letting the computer see the user input early was realized by the engineers of the time. Command completion, where you type the first few letters of a command and the computer fills in the rest, was invented in the mid 1960's. This feature was copied and improved through the years to where it stands today, available in all modern UNIX shells and under Windows as well.
Allowing the CPU to see each character as it is typed also allows shells to offer command line editing and history features well beyond what a dumb terminal could provide. A key can allow you to step back through a list of commands you've previously typed, choose one, and then edit it slightly before pressing RETURN to have it executed. Text can be cut and pasted between command lines, possible because the CPU has access to previous commands while the terminal does not. Filenames as well as commands can be completed based on partial input, again possible because the CPU has access to the names of files in the filesystem and the terminal does not.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/35495
0 comments:
Post a Comment
Let us know your responses and feedback