Try   HackMD

CS:APP 第 10 章重點提示

導讀

System-Level I/O



UNIX 設計哲學: "Everything is a file"

  • 更精確來說是 "Everything is a file descriptor"
  • But file descriptors are also created for things like anonymous pipes and network sockets via different methods
    Page 622 - Page 623

搭配下圖理解 Linux 網路架構:


延伸閱讀: In UNIX Everything is a File



End of line (EOL) indicators in other systems

  • Linux and macOS: \n (0xa): line feed (LF)
  • Windows and Internet protocols: \r\n (0xd 0xa): Carriage return (CR) followed by line feed (LF)



Page 627 - Page 631



Pros and Cons of Unix I/O
slides p.51-54, p.56-58

自我檢查清單

  • tty 是什麼?緣起為何?對 UNIX 的影響又是?
  • 為何 socket 也是一種 file type 呢?具體使用方式為何?
  • RIO package 提供 I/O 封裝的目的為何?對應到真實世界的應用為何?
  • Buffered I/O 的動機和效益為何?
  • fork 系統呼叫後,child process 和 parent process 的檔案分享狀況為何?(提示:閱讀 man-pages)