Paging or segmentation for virtual memory, which is better?
Asked Answered
M

3

6

Most OSes use paging for virtual memory. Why is this? Why not use segmentation? Is it just because of a hardware issue? Is one better than the other in certain cases? Basically, if you had to choose one over the other, which one would you want to use and why?

Let's assume it's an x86 for argument's sake.

Melia answered 2/6, 2011 at 14:50 Comment(3)
Define "better". Development in general (and operating systems in particular) is a case study in trade-offs.Abyss
Also, a lot of this is constrained by the architecture of the systems that you want your operating system to target. For example, there are lots of limitations in the x86 architecture that make paging a far better option.Abyss
@Cody Gray - let's assume x86 then. Why would paging be far better? I I don't really know enough about the actual hardware to know better. Thanks!Melia
A
2

Note, that Single-Address-Space Operating Systems sometimes use segmentation to isolate processes.

Alchemy answered 3/6, 2011 at 17:29 Comment(0)
P
5

Taken from :operating systems concepts by galvin

one of the issues..

Segmentation permits the physical address space of a process to be non- contiguous. Paging is another memory-management scheme that offers this advantage. However, paging avoids external fragmentation and the need for compaction, whereas segmentation does not.

Segmentaion problem: The problem arises because, when code fragments or data residing in main memory need to be swapped out, space must be found on the backing store. The backing store has the same fragmentation problems but access is much slower, so compaction is impossible.

Paging solves it by:

The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called frames and breaking logical memory into blocks of the same size called pages.The backing store is divided into fixed-sized blocks that are the same size as the memory frames or clusters of multiple frames.

Since pages-frames-The backing store all are divided into same size so it doesn't lead to external fragmentation. But may have internal fragmentation. So pagesize must be chosen correctly

Operating Systems concepts

Parkerparkhurst answered 30/3, 2016 at 7:15 Comment(0)
S
4

OS like windows and Linux use a combination of both segmentation and paging. The virtual memory of a process is first divided into segments and then each segment consists of a lot of pages. The OS first goes to the specific segment and in that segment it then locates the particular page to access an address

Sagamore answered 2/6, 2011 at 17:33 Comment(1)
The segment is the whole address space in Linux. It's the same segment table for all the processes.Karsten
A
2

Note, that Single-Address-Space Operating Systems sometimes use segmentation to isolate processes.

Alchemy answered 3/6, 2011 at 17:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.