Program Life in Terms of Paged Segmentation Memory

program life in terms of paged segmentation memory

There's no such thing as paged segmentation, not in the official documentation at least. There are two different mechanisms working together and more or less independently of each other:

  1. Translation of a logical address of the form 16-bit segment selector value:16/32/64-bit segment offset value, that is, a pair of 2 numbers into a 32/64-bit virtual address.
  2. Translation of the virtual address into a 32/64-bit physical address.

Logical addresses is what your applications operate directly with. Then follows the above 2-step translation of them into what the RAM will understand, physical addresses.

In the first step the GDT (or it can be LDT, depends on the selector value) is indexed by the selector to find the relevant segment's base address and size. The virtual address will be the sum of the segment base address and the offset. The segment size and other things in segment descriptors are needed to provide protection.

In the second step the page tables are indexed by different parts of the virtual address and the last indexed table in the hierarchy gives the final, physical address that goes out on the address bus for the RAM to see. Just like with segment descriptors, page table entries contain not only addresses but also protection control bits.

That's about it on the mechanisms.

Now, in many x86 OSes the segment selectors that are used for applications are fixed, they are the same in all of them, they never change and they point to segment descriptors that have base addresses equal to 0 and sizes equal to the possible maximum (e.g. 4GB in non-64-bit modes). Such a GDT setup effectively means that the first step does no useful work and the offset part of the logical address translates into numerically equal virtual address.

This makes the segment selector values practically useless. They still have to be loaded into the CPU's segment registers (in non-64-bit modes into at least CS, SS, DS and ES), but beyond that point they can be forgotten about.

This all (except Linux-related details and the ELF format) is explained in or directly follows from Intel's and AMD's x86 CPU manuals. You'll find many more details there.

In which systems is segmentation with paging (segmented paging) memory management technique used? Give some examples

In which systems is segmentation with paging (segmented paging) memory management technique used?

The only systems that were capable of using both segmentation and paging at the same time for memory management that I'm aware of are:

a) OS/2 ( https://en.wikipedia.org/wiki/OS/2 ) where it was optional and each process could choose "segmented with paging" or "flat paging" and most processes chose "flat paging".

b) Old versions of 32-bit Windows when running even older programs designed for 16-bit Windows (which were designed for "segmentation without any paging")

c) A few (maybe just one) hobbyist and/or niche operating systems that lack notoriety

Note 1: This excludes systems that use segmentation for something else and don't use segmentation for memory management (specifically, recycling an "otherwise unused segment register" so it can be used like a pointer to thread local storage to avoid wasting a more useful general purpose register).

Note 2: I can't guarantee that there isn't one or more other systems that I'm not aware of.

virtual memory effects and relations between paging and segmentation

Why in some sources logical address and virtual addresses are described as synonymes? Do I get something wrong?

Many sources conflate logical and virtual memory translation. In ye olde days, logical address translation never took place without virtual address translation so processor documentation referred to them as the same.

Now we have large memory systems that use logical memory translation without virtual memory.

Is really virtual memory making protection to processes?

It is the logical memory translation that implements page protections.

How really differ paged segmentation from segmented paging.

You can really ignore segments. No rationally designed processor architecture designed after 1970 used segments and they are finally dying out.

If VM make separate address space for each process, does it mean, paging without VM use logic addresses from "one pool"

It is logical memory that creates the separate address space for each process. Paging is virtual memory. You cannot have one without the other.

Differences or similarities between Segmented paging and Paged segmentation?

So,after vigorously searching on net for the difference or similarity between these two terms,I have come up on a final answer.First of all I would write down the similarities:

  • They both (segmented paging and paged segmentation) are a type of paging/segmentation combined systems (Paging and Segmentation can be combined by dividing each segment into pages).
  • In both the system the segments are divided into pages.

Now to describe the differences I will have to define and describe each term separately:

  • Segmented paging- Segments are divided into pages.Implementation requires STR(segment table register) and PMT(page map table).In this scheme, each virtual address consists of a segment number, page number within that segment and an offset within that page.The segment number indexes into segment table which yields the base address of the page table for that segment.The page number indexes into the page table,each of which entry is a page frame.Adding the PFN(page frame number) and the offset results in the physical address.Hence addressing can be described by the following function :

va = (s,p,w) where, va is the virtual address, |s| determines number of
segments (size of ST), |p| determines number of pages per segment (size of
PT), |w| determines page size.

address_map(s, p, w)
{
pa = *(*(STR+s)+p)+w;
return pa;
}

The diagram is here:

Segmented Paging

  • Paged Segmentation- Sometimes segment table or page table may too large to keep in physical memory(they can even reach MBs).Therefore,the segment table is divided into pages too and thus a page table of ST pages is created. The segment number is broken into page no.(s1) and page offset(s2) of page table of ST pages.So,the virtual address can be described as :

va = (s1,s2,p,w)

address_map
(s1, s2, p, w)
{
pa = *(*(*(STR+s1)+s2)+p)+w;
return pa;
}

The diagram description is here:
Paged Segmentation



Related Topics



Leave a reply



Submit