📜  分页和分段的区别

📅  最后修改于: 2021-09-13 01:59:42             🧑  作者: Mango

分页:
分页是一种用于非连续内存分配的方法或技术。它是一个固定大小的分区主题(方案)。在分页中,主内存和辅助内存都被分成相等的固定大小的分区。二级内存区域单元和主内存区域单元的分区分别称为页和帧。

分页是一种内存管理方法,习惯于以页的形式从辅助内存中获取进程到主内存中。在分页中,只要每个部分的大小与页面大小相同,每个进程就会被分成几部分。后半部分的大小也可以只是页面大小。进程区域单元的页面依赖于它们的可访问性在主存储器的框架内保持。

分割:
分段是另一种非连续内存分配方案,如分页。像分页一样,在分段中,进程不会被随意划分为已安装(固定)大小的页面。它是可变大小的分区主题。和分页一样,在分段中,二级内存和主内存没有被分成大小相等的分区。二级内存区域单元的分区称为段。有关每个段的详细信息保存在称为分段表的表中。段表包含两个关于段的主要数据,一个是Base,它是段的底部地址,另一个是Limit,它是段的长度。

在分段中,CPU 生成包含段号和段偏移量的逻辑地址。如果段偏移量小于限制,则该地址称为有效地址,否则会因地址无效而引发计算错误。

上图显示了逻辑地址到物理地址的转换。

分页和分段的区别:

S.NO Paging Segmentation
1. In paging, program is divided into fixed or mounted size pages. In segmentation, program is divided into variable size sections.
2. For paging operating system is accountable. For segmentation compiler is accountable.
3. Page size is determined by hardware. Here, the section size is given by the user.
4. It is faster in the comparison of segmentation. Segmentation is slow.
5. Paging could result in internal fragmentation. Segmentation could result in external fragmentation.
6. In paging, logical address is split into page number and page offset. Here, logical address is split into section number and section offset.
7. Paging comprises a page table which encloses the base address of every page. While segmentation also comprises the segment table which encloses segment number and segment offset.
8. Page table is employed to keep up the page data. Section Table maintains the section data.
9. In paging, operating system must maintain a free frame list. In segmentation, operating system maintain a list of holes in main memory.
10. Paging is invisible to the user. Segmentation is visible to the user.
11. In paging, processor needs page number, offset to calculate absolute address. In segmentation, processor uses segment number, offset to calculate full address.