csd concepts

Upload: crishna411

Post on 03-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Csd Concepts

    1/4

    SEGMENTATION

    INTODUCTION

    Segmentation is a Memory Management technique in which memory is divided into variablesized chunks which can be allocated to processes. Each chunk is called a segment. A table stores

    the information about all such segments and is called Global Descriptor Table (GDT). A GDTentry is called Global Descriptor. It comprise of :

    Logical Address to Linear Address

    To translate a logical address into a linear address, the processor does the following:

    1. Uses the offset in the segment selector to locate the segment descriptor for the segment inthe GDT or LDT and reads it into the processor. (This step is needed only when a newsegment selector is loaded into a segment register.)

    2. Examines the segment descriptor to check the access rights and range of the segment toinsure that the segment is accessible and that the offset is within the limits of thesegment.

    3. Adds the base address of the segment from the segment descriptor to the offset to form alinear address.

    If paging is not used, the processor maps the linear address directly to a physical address (that is,

    the linear address goes out on the processors address bus). If the linear address space is paged, a

    second level of address translation is used to translate the linear address into a physical address.

  • 7/28/2019 Csd Concepts

    2/4

    Segment Selector

    A segment selector is a 16-bit identifier for a segment. It does not point directly to the segment,

    but instead points to the segment descriptor that defines the segment. A segment selectorcontains the following items:

    Index(Bits 3 through 15). Selects one of 8192 descriptors in the GDT or LDT. The processor

    multiplies the index value by 8 (the number of bytes in a segment descriptor) and adds

    the result to the base address of the GDT or LDT (from the GDTR or LDTR register,respectively).

    TI (table indicator) flag(Bit 2). Specifies the descriptor table to use: clearing this flag selects the GDT; settingthis flag selects the current LDT.

    Paging

    Introduction

    Paging is another memory management technique which widely uses virtual memory concept.When paging is used, the processor divides the linear address space into fixed-size pages (of

    4KBytes, 2 MBytes, or 4 MBytes in length) that can be mapped into physical memory and/or

    disk storage. When a program (or task) references a logical address in memory, the processortranslates the address into a linear address and then uses its paging mechanism to translate the

    linear address into a corresponding physical address.

    Linear Page Translation during Paging

  • 7/28/2019 Csd Concepts

    3/4

    If the page containing the linear address is not currently in physical memory, the processor

    generates a page-fault exception (#14). The exception handler for the page-fault exception

    typically directs the operating system to load the page from disk storage into physical memory.

    When the page has been loaded in physical memory, a return from the exception handler causesthe instruction that generated the exception to be restarted. The information that the processor

    uses to map linear addresses into the physical address space and to generate page-faultexceptions (when necessary) is contained in page directories and page tables stored in memory.

    Page-Directory & Page-Table Entries

    Advantages of paging

    Address translation: each task has the same virtual address Address translation: turns fragmented physical addresses into contiguous virtual

    addresses

    Memory protection (buggy or malicious tasks can't harm each other or the kernel) Shared memory between tasks (a fast type of IPC, also conserves memory when used for

    DLLs)

    Demand loading (prevents big load on CPU when a task first starts running, conservesmemory)

    Memory mapped files Virtual memory swapping (lets system degrade gracefully when memory required

    exceeds RAM size)

  • 7/28/2019 Csd Concepts

    4/4