Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. # Chapter 7 Linking
  2.  
  3. - satic linking
  4. - dynamic linking of shared libraries at load time
  5. - dynamic linking of shared libraries at run time
  6.  
  7. C preprocessor(cpp)
  8. ```sh
  9. cpp main.c tmp/main.i
  10. gcc -E main.c
  11. ```
  12. C compiler(cc1)
  13. ```sh
  14. gcc -S main.c tmp/main.s
  15. ```
  16. Assembler(as)
  17. ```sh
  18. as -o tmp/main.o tmp/main.s
  19. gcc -c sum.c -o tmp/sum.o
  20. ```
  21. Linker(ld)
  22. ```sh
  23. ld -o tmp/prog tmp/main.o tmp/sum.o
  24. gcc -o tmp/prog tmp/main.o tmp/sum.o
  25. ```
  26.  
  27. # Chapter 10 System-Level IO
  28.  
  29. Input/output(I/O) is the process of copying data between main memory and external devices such as disk drives, terminals, and networks.
  30. **An input operaton** copies data from an I/O device to main memory
  31. **An output operation** copies data from memory to a device
  32. ```
  33. Unix I/O
  34. |
  35. |derived from
  36. |
  37. ANSI C standrad I/O library C++ standrand I/O library
  38. e.g. printf scanf overloaded >> << operator
  39. ```
  40.  
  41. Each Linux **file** has a **type**
  42. - A *regular file* contains arbitrary data. Applications often distingush between *text files* and *binary files*. To the kernel, there is no difference.
  43. - A *directory* is a file consisting of an array of links, where each link maps a *filename* to a file, which maybe another directory.
  44. - A *socket* is a file that is used to communicate with another process across a network
  45. - other *named pipes, symbolic links, and characterfiles* beyond our scope
  46.  
  47. The kernel represents open files using three related data structures:
  48. - Descriptor table
  49. - File table
  50. - v-node table
  51. ```
  52. Open file table v-node table
  53. Descriptor table (shared by (shared by
  54. (one table per process) all processes) all processes)
  55.  
  56. File A +-----------+
  57. stdin fd0+---+ +--------+ |File access|
  58. stdout fd1|----------------------------> | +---------------->+File size |
  59. stderr fd2|---| |File pos| |File type |
  60. fd3|---| |refcnt=1| |... |
  61. fd4|--------------+ | | +-----------+
  62. fd5+---+ | | |
  63. | +--------+
  64. |
  65. +---------------v File B
  66. +--------+ +-----------+
  67. | +---------------->+File access|
  68. |File pos| |File size |
  69. |refcnt=1| |File type |
  70. | | |... |
  71. | | +-----------+
  72. +--------+
  73. ```
  74. ```
  75. +--------------+
  76. |fopen fdopen |
  77. |fread fwrite |
  78. |fscanf fprintf|
  79. Standard I/O functoins +--------------+
  80.  
  81. ^
  82. |
  83. | +------------+
  84. |open read |
  85. Unix I/O functions |write lseek |
  86. |stat close |
  87. +------------+
  88. ```
  89. # chapter 11 Network Programming
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement