Paging versus segmentation
Paging versus segmentation
Paging is used to get a large linear address space without having to buy more physical memory.With paging, the address space is divided into a sequence of fixed size units called “pages”. And logical addresses take the form of a tuple <page, offset>.Paging helps reduce fragmentation and ensures better memory management.
Computer memory is divided into small partitions that are all the same size and referred to as, page frames. Then when a process is loaded it gets divided into pages which are the same size as those previous frames. The process pages are then loaded into the frames
Segmentation allows programs and data to be broken up into logically independent address spaces and to aid sharing and protection.In segmentation, the address space is typically divided into a preset number of segments like data segment (read/write), code segment(read-only), stack(read/write), heap,bss etc. And the programs are divided into these segments accordingly. Logical addresses are represented as tuple <segment, offset>.Segmentation offers better security since the segments are pre-defined and we can avoid spurious reads/writes at the time of address translations etc.
Computer memory is allocated in various sizes (segments) depending on the need for address space by the process. These segments may be individually protected or shared between processes.Commonly we see what are called “Segmentation Faults” in programs, this is because the data that’s is about to be read or written is outside the permitted address space of that process.
Most modern operating systems employ a combination of both these techniques for their memory management.
Advantages of Segmentation:
Each segment can be
- separately protected
- grow independently
- can be shared between processes
Problems with Segmentation Variable allocation :
- Difficult to find holes in physical memory
- Must use one of non-trivial placement algorithm
- first fit, next fit, best fit, worst fit
External fragmentation
Total memory space is enough to satisfy a request or to reside a process in it, but it is not contiguous so it can not be used.
Internal fragmentation
Memory block assigned to process is bigger. Some portion of memory is left unused as it can not be used by another process.