Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Chapter 7 Linking
- - satic linking
- - dynamic linking of shared libraries at load time
- - dynamic linking of shared libraries at run time
- C preprocessor(cpp)
- ```sh
- cpp main.c tmp/main.i
- gcc -E main.c
- ```
- C compiler(cc1)
- ```sh
- gcc -S main.c tmp/main.s
- ```
- Assembler(as)
- ```sh
- as -o tmp/main.o tmp/main.s
- gcc -c sum.c -o tmp/sum.o
- ```
- Linker(ld)
- ```sh
- ld -o tmp/prog tmp/main.o tmp/sum.o
- gcc -o tmp/prog tmp/main.o tmp/sum.o
- ```
- # Chapter 10 System-Level IO
- Input/output(I/O) is the process of copying data between main memory and external devices such as disk drives, terminals, and networks.
- **An input operaton** copies data from an I/O device to main memory
- **An output operation** copies data from memory to a device
- ```
- Unix I/O
- |
- |derived from
- |
- ANSI C standrad I/O library C++ standrand I/O library
- e.g. printf scanf overloaded >> << operator
- ```
- Each Linux **file** has a **type**
- - A *regular file* contains arbitrary data. Applications often distingush between *text files* and *binary files*. To the kernel, there is no difference.
- - A *directory* is a file consisting of an array of links, where each link maps a *filename* to a file, which maybe another directory.
- - A *socket* is a file that is used to communicate with another process across a network
- - other *named pipes, symbolic links, and characterfiles* beyond our scope
- The kernel represents open files using three related data structures:
- - Descriptor table
- - File table
- - v-node table
- ```
- Open file table v-node table
- Descriptor table (shared by (shared by
- (one table per process) all processes) all processes)
- File A +-----------+
- stdin fd0+---+ +--------+ |File access|
- stdout fd1|----------------------------> | +---------------->+File size |
- stderr fd2|---| |File pos| |File type |
- fd3|---| |refcnt=1| |... |
- fd4|--------------+ | | +-----------+
- fd5+---+ | | |
- | +--------+
- |
- +---------------v File B
- +--------+ +-----------+
- | +---------------->+File access|
- |File pos| |File size |
- |refcnt=1| |File type |
- | | |... |
- | | +-----------+
- +--------+
- ```
- ```
- +--------------+
- |fopen fdopen |
- |fread fwrite |
- |fscanf fprintf|
- Standard I/O functoins +--------------+
- ^
- |
- | +------------+
- |open read |
- Unix I/O functions |write lseek |
- |stat close |
- +------------+
- ```
- # chapter 11 Network Programming
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement