February 20, 2006
Coverage: [USP] Chapters
6
and
7
Comments on Homeworks
- use exit in main as opposed to return, why?
- error checking, error checking, error checking
- objective of a Makefile is not to help compile
the source files of your program in batch
Redirecting Standard Error
$ time alongcommand >/dev/null 2>timelog.txt
$
$ time alongcommand >output.txt 2>&1
$
$ Iwritetostderr 2>&1 | wc -l
shell time vs. UNIX time
- former writes to terminal
- latter writes to standard error
- use fully qualified path: /bin/time
More Job Control
- ;
- nice
- nohup (assumes nice)
- at
- cron
Canonical vs. Noncanonical Modes of Processing Terminal Input
- canonical
- line-at-a-time processing
- read requests do not return until user enters a line delimiter (usually a
newline)
- ERASE and KILL characters work only
on undelimited portion
noncanonical
- uses MIN and TIME parameters
In-class Exercise: Writing a Program to Change our ERASE key to `#'
Experimenting with the Audio Device on Our System
- /dev/audio
- yet another example of the uniformity (consistency) in UNIX i/o
- must use at console
- ioctl function
- gets device status info or sets device control parameters
- has variable argument list
- pass O_NONBLOCK to open to open device
for nonblocking i/o
Introduction to the Token Ring (of Processes)
- nodes = processes
- links = pipes
- each process is a filter
- reads from standard input
- writes to standard output
- simple
- inexpensive
- unidirectional communication: clockwise
- each entity has a connection for input and output
- latency increases as #nodes increase
- bandwidth is independent of ring size (#nodes)
References
[UPE] B. W. Kernighan and R. Pike. The UNIX Programming Environment.
Prentice Hall, Second edition, 1984.
[USP] K. A. Robbins and S. Robbins. UNIX Systems Programming: Concurrency,
Communication, and Threads. Prentice Hall, 2003