APUECh01

5th July 2017 at 10:07am

1.2 UNIX Architecture

1.3 Logging In

Login Name

/etc/passwd stores:

  • login name
  • user id
  • group id
  • etc.

Shell

Explains availability of different shell in different UNIX systems, and their different features and history.

1.5 Input and Output

Unbuffered I/O v.s. Standard I/O

Functions:

FunctionsHeader file
Unbuffered I/Oread, write, etcunistd.h
Standard I/Oscanf, printf, etcstdio.h

By using Standard I/O, you don't need to maintain buffer by yourself.

1.6 Programs and Processes

Process Control

Three primary functions: fork, exec, waitpid. (Didn't explain further)

1.7 Error Handling

The file errno.h defines the symbol errno and many error constants.

man 3 errno describes the meanings of error constants.

errno is never set to 0, so you should examine its value only when the return value from a function indicates that an error occurred.

Helper functions:

SignatureHeader file
char *strerror(int errnum)string.h
void perror(const char *msg)stdio.h

strerror: This function maps errnum, which is typically the errno value, into an error message and returns a pointer to the string.

perror: It outputs the string pointed to by msg, followed by a colon and a space, followed by the error message corresponding to the value of errno, followed by a newline.

1.10 Time Values

  1. Calendar time, also called Epoch time, start from 1970/01/01 00:00:00
  2. Process time, also called CPU time, measured in clock ticks, which have been 50, 60, or 100 ticks per second.

Unix System maintains three values for a process:

  • Clock time
  • User CPU time
  • System CPU time
$ cd /usr/include
$ time -p grep _POSIX_SOURCE */*.h > /dev/null
real 0m0.81s
user 0m0.11s
sys 0m0.07s

1.11 System Calls and Library Functions