Informacion Extraida De: Chapter 3 Protected Mode Memory Management
Informacion Extraida De: Chapter 3 Protected Mode Memory Management
p=945
CHAPTER3PROTECTEDMODEMEMORYMANAGEMENT
ThischapterdescribestheIntelArchitecture's
protectedmodememorymanagementfacilities,including
thephysicalmemoryrequirements,thesegmentation
mechanism,andthepagingmechanism.RefertoChapter4,
Protectionforadescriptionoftheprocessor's
protectionmechanism.RefertoChapter16,8086Emulation
foradescriptionofmemoryaddressingprotectionin
realaddressandvirtual8086modes.
3.1.MEMORYMANAGEMENTOVERVIEW
ThememorymanagementfacilitiesoftheIntel
Architecturearedividedintotwoparts:segmentationand
paging.Segmentationprovidesamechanismofisolating
individualcode,data,andstackmodulessothatmultiple
programs(ortasks)canrunonthesameprocessorwithout
interferingwithoneanother.Pagingprovidesamechanism
forimplementingaconventionaldemandpaged,virtual
memorysystemwheresectionsofaprogram'sexecution
environmentaremappedintophysicalmemoryasneeded.
Pagingcanalsobeusedtoprovideisolationbetween
multipletasks.Whenoperatinginprotectedmode,some
formofsegmentationmustbeused.Thereisnomodebit
todisablesegmentation.Theuseofpaging,however,is
optional.
Thesetwomechanisms(segmentationandpaging)canbe
configuredtosupportsimplesingleprogram(orsingle
task)systems,multitaskingsystems,ormultiple
processorsystemsthatusedsharedmemory.
AsshowninFigure31,segmentationprovidesamechanism
fordividingtheprocessor'saddressablememoryspace
(calledthelinearaddressspace)intosmallerprotected
addressspacescalledsegments.Segmentscanbeusedto
holdthecode,data,andstackforaprogramortohold
systemdatastructures(suchasaTSSorLDT).Ifmore
thanoneprogram(ortask)isrunningonaprocessor,
eachprogramcanbeassigneditsownsetofsegments.The
processorthenenforcestheboundariesbetweenthese
segmentsandinsuresthatoneprogramdoesnotinterfere
withtheexecutionofanotherprogrambywritingintothe
otherprogram'ssegments.Thesegmentationmechanismalso
allowstypingofsegmentssothattheoperationsthatmay
beperformedonaparticulartypeofsegmentcanbe
restricted.
Allofthesegmentswithinasystemarecontainedinthe
processor'slinearaddressspace.Tolocateabyteina
particularsegment,alogicaladdress(sometimescalleda
farpointer)mustbeprovided.Alogicaladdressconsists
ofasegmentselectorandanoffset.Thesegmentselector
isauniqueidentifierforasegment.Amongotherthings
itprovidesanoffsetintoadescriptortable(suchas
theglobaldescriptortable,GDT)toadatastructure
calledasegmentdescriptor.Eachsegmenthasasegment
descriptor,whichspecifiesthesizeofthesegment,the
accessrightsandprivilegelevelforthesegment,the
segmenttype,andthelocationofthefirstbyteofthe
segmentinthelinearaddressspace(calledthebase
addressofthesegment).Theoffsetpartofthelogical
addressisaddedtothebaseaddressforthesegmentto
locateabytewithinthesegment.Thebaseaddressplus
theoffsetthusformsalinearaddressintheprocessor's
linearadressspace.
Figure 3-1
http://faculty.cs.niu.edu/~berezin/463/lec/06memory/vmlayout.ht
ml
VM FIFO example
VM LRU example
VM Table layout
Table size determined by:
Number of Virtual pages =
VM problems
Each memory access requires 2 memory accesses
1st to read the table
2nd to access the page frame in physical memory.
Another issue is size of page table for large systems.
4 GB (2^32) Virtual memory space.
256 MB (2^28) Physical memory.
4 KB (2^12) page and frame size (equal to small cluster).
2^32/2^12 = 2^20 1 Mi. slots. 2^28/2^12 = 2^16 (16 bit pointer)
Table size:
1 Mi.
14 bit timestamp)
1.5 x
Windows default allocates a minimum size and then adds to it. When
not needed the additional drive space is freed for other use. Because
the VM system works in 4 K frames, defragmentation is a minor issue.
Part of the efficiency of the VM model is based on working with
standard sized pages.
However,
Even if program or data does not take up all bytes of a frame,
All bytes are reserved for specific page.
If many small blocks of memory,
Much space is wasted.
This is known as internal fragmentation.
Since most programs and blocks of data span several virtual pages,
The percentage of partial frames tend to be small.
Alternative is to use segmentation.