Nonblocking IO (ITI8510): erinevus redaktsioonide vahel
Mine navigeerimisribale
Mine otsikasti
| 6. rida: | 6. rida: | ||
'''Hints:''' | '''Hints:''' | ||
* Try to put the terminal into noncanonical mode | * Try to put the terminal into noncanonical mode and remove terminal echo See '[http://linux.die.net/man/3/termios man termios]' or [ [http://www.google.ee/search?q=noncanonical+mode Google] for that. | ||
* Note that you should restore the terminal mode before quitting since otherwise the terminal might get messed up (no echo). | * Note that you should restore the terminal mode before quitting since otherwise the terminal might get messed up (no echo). | ||
* Working with bits: | * Working with bits: | ||
Redaktsioon: 18. veebruar 2010, kell 17:53
We have two tasks today. Both with practicing nonblocking IO.
1. Canonical mode
Goal: To write a program which echoes characters on screen while typed until button 'q' is pressed. Then prints a newline.
Hints:
- Try to put the terminal into noncanonical mode and remove terminal echo See 'man termios' or [ Google for that.
- Note that you should restore the terminal mode before quitting since otherwise the terminal might get messed up (no echo).
- Working with bits:
flags &= ~NEWFLAG // Clears the bit NEWFLAG on flags flags |= NEWFLAG // Set the bit NEWFLAG on flags flags ^= NEWFLAG // Toggle NEWLAG
2. Nonblocking reading from a FIFO
Goal: To write a program which prints a '.' character every half-a second unless some input is provided on a fifo file.
Hints: