Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Memory segmentation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Hardware implementation== In a system using segmentation, computer memory addresses consist of a segment id and an offset within the segment.<ref name="glaser1965"/> A hardware [[memory management unit]] (MMU) is responsible for translating the segment and offset into a [[physical address]], and for performing checks to make sure the translation can be done and that the reference to that segment and offset is permitted. Each segment has a length and set of permissions (for example, ''read'', ''write'', ''execute'') associated with it.<ref name="glaser1965"/> A [[process (computing)|process]] is only allowed to make a reference into a segment if the type of reference is allowed by the permissions, and if 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. Segments may also be used to implement [[virtual memory]]. In this case each segment has an associated flag indicating whether it 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. Segmentation is one method of implementing [[memory protection]].<ref name="ostep-1">{{cite book |title=Operating Systems: Three Easy Pieces |chapter=Segmentation |chapter-url=http://pages.cs.wisc.edu/~remzi/OSTEP/vm-segmentation.pdf |publisher=Arpaci-Dusseau Books |date=2014 |first1=Remzi H. |last1=Arpaci-Dusseau |first2=Andrea C. |last2=Arpaci-Dusseau}}</ref> [[Page (computer memory)|Paging]]<!-- please, do not "simplify" or "fix" the link. The [[paging]] article is about a virtual memory technique, not about memory protection --> is another, and they can be combined. The size of a memory segment is generally not fixed and may be as small as a single [[byte]].<ref>{{cite book |publisher=Intel Corporation |title=Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B & 3C): System Programming Guide |date=2012 |pages=3β13 |url=http://download.intel.com/products/processor/manual/325384.pdf}}</ref> Segmentation has been implemented several ways on various hardware, with or without paging. Intel [[x86 memory segmentation]] does not fit either model and is discussed separately below, and also in greater detail in a separate article. ===Segmentation without paging=== Associated with each segment is information that indicates where the segment is located in memory— the ''segment base''. When a program references a memory location, the offset is added to the segment base to generate a physical memory address. An implementation of virtual memory on a system using segmentation without paging requires that entire segments be swapped back and forth between main memory and secondary storage. When a segment is swapped in, the operating system has to allocate enough contiguous free memory to hold the entire segment. Often [[fragmentation (computing)|memory fragmentation]] results if there is not enough contiguous memory even though there may be enough in total. ===Segmentation with paging=== Instead of a memory location, the segment information includes the address of a [[page table]] for the segment. When a program references a memory location the offset is translated to a memory address using the page table. A segment can be extended by allocating another memory page and adding it to the segment's page table. An implementation of [[virtual memory]] on a system using segmentation with paging usually only moves individual pages back and forth between main memory and secondary storage, similar to a paged non-segmented system. Pages of the segment can be located anywhere in main memory and need not be contiguous. This usually results in a reduced amount of input/output between primary and secondary storage and reduced memory fragmentation.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)