Drivers – Difference Between Raw and Cooked Device Drivers

devicesdriversterminal

Does this concept only apply to terminal drivers (which is what most sites cover) or to any driver in general?

Best Answer

The terms raw and cooked only apply to terminal drivers. "Cooked" is called canonical and "raw" is called non-canonical mode.

The terminal driver is, by default a line-based system: characters are buffered internally until a carriage return (Enter or Return) before it is passed to the program - this is called "cooked". This allows certain characters to be processed (see stty(1)), such as CtrlD, CtrlS, CtrlU, Backspace); essentially rudimentary line-editing. The terminal driver "cooks" the characters before serving them up.

The terminal can be placed into "raw" mode where the characters are not processed by the terminal driver, but are sent straight through (it can be set that INTR and QUIT characters are still processed). This allows programs like emacs and vi to use the entire screen more easily.

You can read more about this in the "Canonical mode" section of the termios(3) manpage.


Related Question