16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

I/O Subsystem<br />

Terminal Drivers<br />

- Internally implement a "line discipline" which interprets <strong>the</strong> users' I/O.<br />

- In "canonical" mode, <strong>the</strong> line discipline converts <strong>the</strong> "raw" sequences typed by <strong>the</strong> user to a canonical form<br />

(what <strong>the</strong> user meant) before sending <strong>the</strong>m to <strong>the</strong> user process.<br />

- In "raw" mode, <strong>the</strong> line discipline passes data between <strong>the</strong> process and <strong>the</strong> user <strong>with</strong>out conversion.<br />

Functions of <strong>the</strong> Line Discipline<br />

- Parse input strings into lines.<br />

- Process "erase" (backspace-type) characters.<br />

- Process a "kill" character (all of present line).<br />

- Echo received characters.<br />

- Expand output e.g.: tab spaces<br />

- Generate signals e.g.: user hitting <strong>the</strong> interrupt key.<br />

- Allow a "raw" mode.<br />

Terminal I/O is buffered<br />

- Line disciplines manipulate "clists" (character list).<br />

Figure 32. Data Sequence and Data Flow through Line Dicsipline<br />

- Variable length linked list of CBlocks <strong>with</strong> a count of <strong>the</strong> number of characters on <strong>the</strong> list.<br />

- CBlock contains:<br />

- Pointer to next CBlock on list<br />

- Character array<br />

- Start & end offsets for data<br />

Next Start End Character Array<br />

Ptr Offset Offset 0123456 ...<br />

| 7 | 14 | garbage ...<br />

Kernel manages Clists and CBlocks<br />

- Keeps a list of free CBlocks<br />

A Cist is a variable linked list of Cblocks<br />

- Can do <strong>the</strong> following:<br />

1. Assign a free CBlock to a driver<br />

2. Return a CBlock to <strong>the</strong> free list<br />

3. Retrieve first character from a Clist (null if none)<br />

146

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!