+ All Categories
Home > Technology > Memory mgmt 80386

Memory mgmt 80386

Date post: 20-Jan-2015
Category:
Upload: akshay-nagpurkar
View: 1,867 times
Download: 4 times
Share this document with a friend
Description:
Memory Management
Popular Tags:
24
Memory Segmentation
Transcript
Page 1: Memory mgmt 80386

Memory Segmentation

Page 2: Memory mgmt 80386

Segment

Different method of defining memory segments as compared to 8086.

User’s program can not access any processor's address space merely by asking.

In 80386, a program can not access an area of memory unless that area has been described to it.

Segment violation if try to access 80386 processor does not enforce segment

boundaries and alignment, as it did in 8086. Systems programmer defines what each segment

will be.

Page 3: Memory mgmt 80386

Segment …cntd….

Segment definition includes Its starting address Its length Its intended use Other attributes

Segment length is variable form 1 byte to 4 GB.

Base address defines actual address so sixteen byte alignment is no longer required

Page 4: Memory mgmt 80386

Segment

Segments are Areas of memory Defined by the programmer Used for different purposes, such as

code, data and stack Segments are not

All the same size. Necessarily paragraph aligned Limited to 64KB

Page 5: Memory mgmt 80386

Segment Descriptors

A special structure used to describe a segment.

Exactly one descriptor must be defined for each segment.

U can define virtually any number of segment descriptors.

Ability to define segment descriptors carries considerable power and responsibility for system security.

Page 6: Memory mgmt 80386

A segment Descriptor

Describes a segment Must be created for every segemnt Is created by the programmer Determines a segment’s base address Determines a segment’s size Determines a segment's use Determines a segment’s use Determines a segment’s privilege level

Page 7: Memory mgmt 80386

Segment Descriptors field

Base Address of segment(0-FFFFFFFF)

Length of segment(0-FFFFFFFF)

Segment Type

Privilege Level

Miscellaneous

Page 8: Memory mgmt 80386

Segment Descriptor format

Page 9: Memory mgmt 80386

Segment types

000=Data, read only 001=Data, read/write 010=Stack, read only 011=stack read/write 100=code, execute only 101=code, execute/read 110=code, execute only, conforming 111=code, execute/read, conforming

Page 10: Memory mgmt 80386

Segments can be defined in eight basic types

Executable code segments with or without data read permission

Executable code segments with or without privilege protection

Data segments with or without write permission

Stack segments with or without write permission

Page 11: Memory mgmt 80386

Descriptor Table

Group arrangement of descriptors is known as a descriptor table.

Order is not important. Max size of table=64 Kb, so can have only

one descriptor or as many as 8192.

Page 12: Memory mgmt 80386

Descriptors are stored in three tables:

Global Descriptor table(GDT) Maintains a list of most segement May contains special “System descriptors”

Interrupt Descriptor Table (IDT) Maintains a list of interrupt service routine

Local Descriptor Table (LDT) Is optional Extends range of GDT Is allocated to each task when multitasking is enabled

Page 13: Memory mgmt 80386

After u have placed each descriptor in a descriptor table, you need to inform the processor

U can place theses tables anywhere in the processor’s address space and u need not keep them together.

To allow processor to locate the GDT, IDT and current LDT, u load three special purpose registers, GDTR, IDTR,LDTR resply.

Page 14: Memory mgmt 80386

GDTR,IDTR,LDTR contains

Base address of table Limit

Page 15: Memory mgmt 80386

Segment Selectors

Once the descriptors are defined , how does the processor make use of them?

Any 16 bit value that u write into a segment register is called a selector, because it selects a segment descriptor from a descriptor table.

15 2 1 0

INDEX RPLTI

Page 16: Memory mgmt 80386

80386 segment registers

80386 has 6 segment registers One for current code segment(CS) One for current stack segment (SS) Four for general data segments (DS, ES,FS,GS)

Segment registers select segment descriptors: Thirteen bits select descriptors One bit selects descriptor table Two bits privilege checking

Page 17: Memory mgmt 80386

Loading Segment Selectors

Any given selector value selects one and only one descriptor

When loading segment selector ,the 80386 check that The selector index is within the descriptor table limit The selector references the correct descriptor table The descriptor is of correct type The selector uses the correct privilege level

Page 18: Memory mgmt 80386

GDT

GDT 0GDT 1GDT 2

GDTR

Offset

Index

2 1 0

TI RPL

Page 19: Memory mgmt 80386

SEGMENTATION

Addressing

Index

2 1 0

TI RPL

GDT

GD 0

GD 1GD 2

GDTR

Offset

Prog

GDT

Main Memory

Page 20: Memory mgmt 80386

Addressing

Index

3 2 1 0

TI RPL

GDT

GD 0GD 1

GD 2

GDTR

Main Memory

Base AddressSeg Limit

Attrib

Offset

Page 21: Memory mgmt 80386

GD 0

GD 1

GD 2

GDTR

Index

2 1 0

TI RPL

GDT

Base AddressSeg Limit

Attrib

+

Offset

Page 22: Memory mgmt 80386

Local Descriptor Tables(LDT’s)

LDT’s act like extension to GDT Are assigned to individual tasks when task

switching is done. While running, any program can assess

descriptors from GDT and LDT The way in which the processor locates

LDT’s is much different, however.

Page 23: Memory mgmt 80386

Descriptor

LDT Descriptor

Descriptor

Descriptor

Data Descriptor

Descriptor

GDT

LDT

GDTR

LDTR

1DS

ESI

Page 24: Memory mgmt 80386

Local Descriptor table

Hold segment descriptors May be used in addition to the global descriptor

table Are defined by special “system descriptor” in

GDT. May be larger or smaller than GDT. May not be define other LDTs


Recommended