Schematic View of Swapping operating system process ap out P process swap In user backing store maIn memory Applied Operating System Concepts 9.11 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.11 Schematic View of Swapping
Contiguous allocation Main memory usually divided into two partitions:(主存通常被分为两部 分) Resident operating system, usually held in low memory with nterrupt vector..(为操作系统保留的部分,通常用中断矢量保存在内 存低端。) User processes then held in high memory.(用户进程保存在内存高 端。) Single- partition allocation(单独分区分配) Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data.( 基址寄存器策略由来保护用户进程(同其他进程和改变的操作系统代码 和数据分开。) Relocation register contains value of smallest physical address limit register contains range of logical addresses -each logical address must be less than the limit register.(基址寄存器包含最小 物理地址的值;限长寄存器包含逻辑地址的范围,每个逻辑地址必需比 限长寄存器的值小。) Applied Operating System Concepts 9.12 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.12 Contiguous Allocation • Main memory usually divided into two partitions:(主存通常被分为两部 分) – Resident operating system, usually held in low memory with interrupt vector.(为操作系统保留的部分,通常用中断矢量保存在内 存低端。) – User processes then held in high memory.(用户进程保存在内存高 端。) • Single-partition allocation(单独分区分配) – Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data.( 基址寄存器策略由来保护用户进程(同其他进程和改变的操作系统代码 和数据分开。) – Relocation register contains value of smallest physical address; limit register contains range of logical addresses – each logical address must be less than the limit register. (基址寄存器包含最小 物理地址的值;限长寄存器包含逻辑地址的范围,每个逻辑地址必需比 限长寄存器的值小。)
Contiguous Allocation(Cont) Mu| tiple-partition allocation(多分区分配) Hole- block of available memory holes of various size are scattered throughout memory.(分区一可用的内存块 ,不同大小的分区分布在整个内存中。) When a process arrives, it is allocated memory from a hole large enough to accommodate it.(当一个进程到来 的时候,它将从一个足够容纳它分区中分配内存。) Operating system maintains information about(操作系 统包含以下信息):a) allocated partitions(分配的分区) b) free partitions(hole)(空的分区) process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 10 process 2 process 2 process 2 process 2 Applied Operating System Concepts 9.13 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.13 Contiguous Allocation (Cont.) • Multiple-partition allocation(多分区分配) – Hole – block of available memory; holes of various size are scattered throughout memory.(分区—可用的内存块 ,不同大小的分区分布在整个内存中。) – When a process arrives, it is allocated memory from a hole large enough to accommodate it.(当一个进程到来 的时候,它将从一个足够容纳它分区中分配内存。) – Operating system maintains information about(操作系 统包含以下信息):a) allocated partitions (分配的分区) b) free partitions (hole)(空的分区) OS process 5 process 8 process 2 OS process 5 process 2 OS process 5 process 2 OS process 5 process 9 process 2 process 9 process 10
Dynamic Storage-Allocation Problem How to satisfy a request of size n from a list of free holes. (怎样从一个空的分区序列中满足一个申请需要。) First-fit(首先适应): Allocate the first hole that is big enough.(分配最先找到的合适的分区。) Best-fit(最佳适应): Allocate the smallest hole that is big enough: search el s ordered Produces the smallest leftover hole.(搜索整个序列,找到适 合条件的最小的分区进行分配。) ° Worst-fit(最差适应): Allocate the largest hole; must also search entier list. Produces the largest leftover hole. (2 整个序列,寻找最大的分区进行分配。) First-fit and best-fit better than worst-fit in terms of speed and storage utilization.(在速度和存储的利用上,首先适应 和最佳适应要比最差适应好。) Applied Operating System Concepts 9.14 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.14 Dynamic Storage-Allocation Problem • First-fit(首先适应): Allocate the first hole that is big enough.(分配最先找到的合适的分区。) • Best-fit(最佳适应): Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. (搜索整个序列,找到适 合条件的最小的分区进行分配。) • Worst-fit(最差适应): Allocate the largest hole; must also search entier list. Produces the largest leftover hole.(搜索 整个序列,寻找最大的分区进行分配。) How to satisfy a request of size n from a list of free holes. (怎样从一个空的分区序列中满足一个申请需要。) First-fit and best-fit better than worst-fit in terms of speed and storage utilization.(在速度和存储的利用上,首先适应 和最佳适应要比最差适应好。)
Fragmentation External fragmentation(外碎片)一 total memory space exists to satisfy a request, but it is not contiguous.(整个内存空间用来满足一个请求,但它不是 连续的。) nternal fragmentation(内碎片)- allocated memory may be slightly larger than requested memory this size difference is memory internal to a partition, but not being used.(分配的内存可能比申请的内存大一点,这两者 之间的差别是内部不被使用的簇) Reduce external fragmentation by compaction(通过压缩来减少内碎片) Shuffle memory contents to place all free memory together in one large block.(把一些小的空闲内存结合成一个大的块。) Compaction is possible only if relocation is dynamic, and is done at execution time.(只有重置是动态的时候,才有可能进行压缩,压缩在执行 时期进行) o problen(O问题) Latch job in memory while it is involved in I/O.(当O的时候,把工 作锁定在内存中。) Do lO only into oS buffers.(只对操作系统的缓冲区进行o。) Applied Operating System Concepts 9.15 Silberschatz, Galvin, and Gagne @1999
Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 9.15 Fragmentation • External fragmentation(外碎片)– total memory space exists to satisfy a request, but it is not contiguous.(整个内存空间用来满足一个请求,但它不是 连续的。) • Internal fragmentation(内碎片) – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.(分配的内存可能比申请的内存大一点,这两者 之间的差别是内部不被使用的簇) • Reduce external fragmentation by compaction(通过压缩来减少内碎片) – Shuffle memory contents to place all free memory together in one large block.(把一些小的空闲内存结合成一个大的块。) – Compaction is possible only if relocation is dynamic, and is done at execution time.(只有重置是动态的时候,才有可能进行压缩,压缩在执行 时期进行) – I/O problem(I/O问题) Latch job in memory while it is involved in I/O.(当I/O的时候,把工 作锁定在内存中。) Do I/O only into OS buffers.(只对操作系统的缓冲区进行I/O。)