Satyam Dwivedi
Satyam Dwivedi

Reputation: 162

Segmentation VS Paging performance difference and application in OS

I wanted to know what exactly is the performance gain of using paging over segmentation in modern operating systems as one suffers from external fragmentation and the other from internal fragmentation and both have to refer the respective tables once and then refer to the memory location pointed to extract the information(ignoring TLB for once).

What exactly is the reason of discarding segmentation usage in modern OS and using paging knowing that there is some form of fragmentation still there in the system?

Upvotes: 1

Views: 207

Answers (1)

mevets
mevets

Reputation: 10445

It is a common error to presume that segmentation refers to the implementation of the segment based protection mechanism in the intel 432, 80[2345]86 architectures, and the vestigial remnants carried into the AMD64 architecture. Segmented architectures existed at least 20 years before the 432 or 80286 ever saw the light of lithography.

In general terms, the management of segments which were the last phase of translation, was troublesome because simply growing a segment could require copying a large amount of memory.

In more specific terms, for example the intel 80x86 architecture, the page-level translation occurred after the segment translation. This meant that the changing the allocation base of a segment merely required relocating page table entries, so really not a big deal.

Unfortunately, in the intel case, it meant that pointers had to be constructed of a pair: (seg, offset). Two pointers could thus only be reasonable compared or computed if their seg component matched, and the notion of such an odd pointer caused all sorts of programming difficulties.

Despite that some operating systems employed segmentation: OS2 and QNX are ones I am familiar with. OS/2, may or may not have been performant; I never got past diskette 18 of the 32 diskette installation system.

QNX, however, was a marvelously performing operating system, being both able to squeeze into very small footprints, and well utilize large footprints of the day. In those days small footprints were < 1M (yes, 10^6), and large ones 64M ( 64 * 10^6 ). It employed segment translation over page translation as described above. For 32 bit programs, it only supported a non-segmented application model, however the underlying system extensively used segments as high speed aliasing and protection devices. 16 bit programs suffered with the ugly segment model.

TL;DR Intel's segment model is only one, and arguably amongst the worst.

Operating systems can employ it transparently for a variety of optimisations.

Other segmentation models are less intrusive, but have fallen almost out of favour.

ARM architecture has a MPU which is a flexible segment based protection unit, however performs no translation.

Upvotes: 2

Related Questions