文档详情

计算机系统第10章.pdf

发布:2020-09-14约4.4万字共46页下载文档
文本预览下载声明
School of Computer Science and Technology, HITSchool of Computer Science and Technology, HIT 第10章系统级I/O 教 师:吴锐 计算机科学与技术学院 哈尔滨工业大学 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition 1 School of Computer Science and Technology, HITSchool of Computer Science and Technology, HIT 主要内容  Unix I/O  用RIO包健壮地读写  读取文件元数据,共享和重定位  标准I/O  结束语 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition 2 School of Computer Science and Technology, HITSchool of Computer Science and Technology, HIT Unix I/O  一个Linux 文件就是一个m 字节的序列:  B , B , , B , , B 0 1 k m-1  现实情况: 所有的I/O设备都被模型化为文件:  /dev/sda2 (用户磁盘分区)  /dev/tty2 (终端)  甚至内核也被映射为文件:  /boot/vmlinuz-3.13.0-55-generic (内核映像)  /proc (内核数据结构) Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition 3 School of Computer Science and Technology, HITSchool of Computer Science and Technology, HIT Unix I/O  这种将设备优雅地映射为文件的方式,允许Linux 内 核引出一个简单、低级的应用接口,称为Unix I/O:  打开和关闭文件  open()and close()  读写文件  read() and write()  改变当前的文件位置 (seek)  指示文件要读写位置的偏移量  lseek() B B • • • B B B • • • 0 1 k-1 k k+1 文件当前位置= k Bryant and O’Hallaron, Computer Systems: A Programm
显示全部
相似文档