Memory - Segment

1 - About

A memory segment is a division part of the primary memory and is an important component of a segmentation based virtual memory.

Segments usually represent natural divisions of a program and may be created to separate:

  • code (individual routines)
  • and data (data tables)

Certain segments may even be shared between programs. See: shared memory

3 - Property

3.1 - Identification

A segment is identified by:

3.2 - Size

The size of a memory segment is generally not fixed and may be as small as a single byte.

4 - Location

4.1 - Translation

The memory management unit (MMU) is responsible to translate a segment and offset into a memory address.

An address is associated with a segment that indicates where the segment is located in memory. The meaning of the address differs with the use or not of paging.

The address might be:

  • without paging: the address of the first location in the segment,
  • with paging: the address of a page table for the segment

4.1.1 - Without paging

When a segment does not have a page table associated with it, the address of the first location in the segment is usually an address in main memory (in those situations, no paging is done).

The offset within the segment will be added to address of the first location in the segment to give the address in memory of the referred-to item.

4.1.2 - With Paging

The address is an address in a paged address space. The offset of the segment is translated to a memory address using the page table.

4.2 - Main memory or not

Segments may also have a flag indicating whether the segment is present in main memory or not; if a segment is accessed that is not present in main memory, an exception is raised, and the operating system will read the segment into memory from secondary storage.

5 - Permission

A segment has:

  • a length (size)
  • and a set of permissions associated with it.

A process is only allowed to make a reference into a segment if the type of reference is allowed by the permissions, and the offset within the segment is within the range specified by the length of the segment. Otherwise, a hardware exception such as a segmentation fault is raised.

6 - Documentation / Reference

data_storage/memory_segment.txt ยท Last modified: 2017/10/27 15:54 by gerardnico