The Design Of Unix Operating System (4) Buffer cache

  • A logical disk block should not be mapped to two buffers.
  • Each buffer contains a buffer header, which include fileds: the logic device number, logic block number, the status of the buffer, and two sets of pointers to data arrays.

device number

block number

status

pointer to data area

pointer to next buffer on hash queue

pointer to previous buffer on hash queue

pointer to next buffer on free list

pointer to previous buffer on free list

                                      buffer header

  • The kernel uses Least Recently Used algorithm to allocate a buffer to the data block.
  • The kernal maints a double linked list of free buffers, and in the mean while it uses a hash queue to organise the buffers allocated to the device blocks, as shown below, which will help to find the blocks ASAP. The hash is calculated with device number and block number. A buffer might be contained in both the free list and the hass queue  list.                                                                                                                   
    blockno 0 mod 4 | pointer to buff queue
    blockno 1 mod 4 | pointer to buff queue
    blockno 2 mod 4 | pointer to buff queue
    blockno3 mode 4| pointer to buff queue
            buffers on the hash queues
     
  • The user programs do Not need to care about data alignment in his program(not a network communication program), because the kernel will copy the data from user buffer to kernel buffer, and the kernel will handle data alignemtn subsequently.
第1章 系统概貌 1.1 历史 1.2 系统结构 1.3 用户看法 1.3.1 文件系统 1.3.2 处理环境 1.3.3 构件原语 1.4 操作系统服务 1.5 关于硬件的假设 1.5.1 中断与例外 1.5.2 处理机执行级 1.5.3 存储管理 1.6 本章小结 第2章 内核导言 2.1 UNIX操作系统的体系结构 2.2 系统概念介绍 2.2.1 文件子系统概貌 .2.2.2 进程 2.3 内核数据结构 2.4 系统管理 2.5 本章小结 2.6 习题 第3章 数据缓冲区高速缓冲 3.1 缓冲头部 3.2 缓冲池的结构 3.3 缓冲区的检索 3.4 读磁盘块与写磁盘块 3.5 高速缓冲的优点与缺点 3.6 本章小结 3.7 习题 第4章 文件的内部表示 4.1 索引节点 4.1.1 定义 4.1.2 对索引节点的存取 4.1.3 释放索引节点 4.2 正规文件的结构 4.3 目录 4.4 路径名到索引节点的转换 4.5 超级块 4.6 为新文件分配索引节点 4.7 磁盘块的分配 4.8 其他文件类型 4.9 本章小结 4.10 习题 第5章 文件系统的系统调用 5.1 系统调用open 5.2 系统调用read 5.3 系统调用write 5.4 文件和记录的上锁 5.5 文件的输入/输出位置的调整—lseek 5.6 系统调用close 5.7 文件的建立 5.8 特殊文件的建立 5.9 改变目录及根 5.10 改变所有者及许可权方式 5.11 系统调用stat和fstat 5.12 管道 5.12.1 系统调用pipe 5.12.2 有名管道的打开 5.12.3 管道的读和写 5.12.4 管道的关闭 5.12.5 例 5.13 系统调用dup 5.14 文件系统的安装和拆卸 5.14.1 在文件路径名中跨越安装点 5.14.2 文件系统的拆卸 5.15 系统调用link 5.16 系统调用unlink 5.16.1 文件系统的一致性 5.16.2 竞争条件 5.17 文件系统的抽象 5.18 文件系统维护 5.19 本章小结 5.20 习题 第6章 进程结构 6.1 进程的状态和状态的转换 6.2 系统存储方案 6.2.1 区 6.2.2 页和页表 6.2.3 内核的安排 6.2.4 u区 6.3 进程的上下文 6.4 进程上下文的保存 6.4.1 中断和例外 6.4.2 系统调用的接口 6.4.3 上下文切换 6.4.4 为废弃返回(abortive return)而保存上下文 6.4.5 在系统和用户地址空间之间拷贝数据 6.5 进程地址空间的管理 6.5.1 区的上锁和解锁 6.5.2 区的分配 6.5.3 区附接到进程 6.5.4 区大小的改变 6.5.5 区的装入 6.5.6 区的释放 6.5.7 区与进程的断接 6.5.8 区的复制 6.6 睡眠 6.6.1 睡眠事件及地址 6.6.2 算法sleep和wakeup 6.7 本章小结 6.8 习题 第7章 进程控制 7.1 进程的创建 7.2 软中断信号 7.2.1 软中断信号的处理 7.2.2 进程组 7.2.3 从进程发送软中断信号 7.3 进程的终止 7.4 等待进程的终止 7.5 对其他程序的引用 7.6 进程的用户标识号 7.7 改变进程的大小 7.8 shell程序 7.9 系统自举和进程init 7.10 本章小结 7.11 习题 第8章 进程调度和时间 8.1 进程调度 8.1.1 算法 8.1.2 调度参数 8.1.3 进程调度的例子 8.1.4 进程优先权的控制 8.1.5 公平共享调度 8.1.6 实时处理 8.2 有关时间的系统调用 8.3 时钟 8.3.1 重新启动时钟 8.3.2 系统的内部定时 8.3.3 直方图分析 8.3.4 记帐和统计 8.3.5 计时 8.4 本章小结 第9章 存储管理策略 9.1 对换 9.1.1 对换空间的分配 9.1.2 进程的换出 9.1.3 进程的换入 9.2 请求调页 9.2.1 请求调页的数据结构 9.2.2 偷页进程 9.2.3 页面错 9.2.4 在简单硬件支持下的请示调页系统 9.3 对换和请示调页的混合系统 9.4 本章小结 9.5 习题 第10章 输入/输出子系统 10.1 驱动程序接口 10.1.1 系统配置 10.1.2 系统调用与驱动程序接口 10.1.3 中断处理程序
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值