SlideShare une entreprise Scribd logo
1  sur  85
Télécharger pour lire hors ligne
Memory Management
    Structure
Learning Objectives













    |   (OS: Operating Systems) |   (Memory Management) | 2
Agenda

                         (Background)
                       (Swapping)
                                                            (Contiguous
    Allocation)
                     (Paging)
                                        (Segmentation)

        (Segmentation with Paging)




    |      (OS: Operating Systems) |        (Memory Management) | 3
Background



                                        (instruction-execution cycle)

                  (fetch)

                     decode                                              1



                        execution                                            2

               (store)


    |       (OS: Operating Systems) |           (Memory Management) | 4
Background (2)

                                       (machine code)


                             Input queue
        









    |       (OS: Operating Systems) |        (Memory Management) | 5
Background (3)




    6.1


|         (OS: Operating Systems) |     (Memory Management) | 6
Background (3)
                                                                               (run)


                           Compile time
        
            (absolute address)

                            Load time
        
                                                                (relocatable)
                                     Execution time
        



                                                                                (run
            time)
            (e.g., base and limit registers)

    |           (OS: Operating Systems) |         (Memory Management) | 7
6.2
|   (OS: Operating Systems) |   (Memory Management) | 8
Logical vs. Physical Address Space


                                   Logical address
                                                                               (virtual
            address)
                                          Physical address
        
                                    (memory-address register)





                                           (logical address space)

                                                              (physical address space)


    |          (OS: Operating Systems) |              (Memory Management) | 9
Memory-Management Unit (MMU)

                                                             Logical Address
                             Physical Address
                       Relocation

                 MMU

    (relocate register)


                                                                 logical
    addresses                             MMU
                                          real physical


      |       (OS: Operating Systems) |          (Memory Management) | 10
Dynamic relocation using a relocation register


|     (OS: Operating Systems) |   (Memory Management) | 11
Dynamic Loading



                                       dynamic loading)
                                                                         relative
    memory
                       (routine)







    (library routine)
    |       (OS: Operating Systems) |         (Memory Management) | 12
Dynamic Linking
 OS                                                                     (static
    linking)

                                             execution time

                                (stub)

 stub


                                                                             routine
    library                                (shared libraries)




    |          (OS: Operating Systems) |      (Memory Management) | 13
 Static Linked Library (Link

                   EXE
 Dynamic Linked Library (Link

                   EXE
        DLL
                 DLL




                                                     DOS            Static linked

              |         (OS: Operating Systems) |   (Memory Management) | 14




                         Overlay
                             Swapping
                                        Single Partition Allocation
                                        Multiple Partition Allocation




    |       (OS: Operating Systems) |     (Memory Management) | 15
Overlay



              (overlay)









    |   (OS: Operating Systems) |        (Memory Management) | 16
Overlay

                                                       Compiler
    Assemble






                                                                (Overlay)




    |    (OS: Operating Systems) |        (Memory Management) | 17
|   (OS: Operating Systems) |   (Memory Management) | 18
Swapping

                  (swap)
                                                                                  (virtual Memory)
                                     Backing store
    
                                                        -
            direct access
                                         Roll out, roll in
    
                                     (priority base)
    







        |          (OS: Operating Systems) |           (Memory Management) | 19
Schematic View of Swapping




6.5


 |    (OS: Operating Systems) |   (Memory Management) | 20
(Single Partition Allocation)
                                               2
                System
             User

                                         Batch system)      DOS




            USER




            OS



    |         (OS: Operating Systems) |              (Memory Management) | 21
                     User Area)                System





                           Process1




                                               Error




                                OS



    |   (OS: Operating Systems) |     (Memory Management) | 22
Contiguous Allocation


                                   Resident OS),
        interrupt vector
    

            OS
        (transient)




        |        (OS: Operating Systems) |          (Memory Management) | 23
Contiguous Allocation

                                     Resident OS),
        interrupt vector
    

            OS
        (transient)
                                               (fixed-size partition)
    Single-partition allocation
                                                Relocation-register scheme
                                                                                    OS

    
        base register                          Offset
                                                                                        limit
        register

        |          (OS: Operating Systems) |             (Memory Management) | 24
Base register              limit register


|   (OS: Operating Systems) |          (Memory Management) | 25
|   (OS: Operating Systems) |   (Memory Management) | 26
(Multiple Partition Allocation)

                                                                Single
    Partition
           2
           Fixed Sized Partition            Partition

           Dynamic Allocation                       Partition




    |           (OS: Operating Systems) |   (Memory Management) | 27
Fix Sized Partition

                500B
                                                        1000B
                                2 Partition




                                                        2100B

                                3 Partition


                                              ?




|   (OS: Operating Systems) |                 (Memory Management) | 28
Fix Sized Partition


                                1200B


                       1200B




                                    2580B

                      2580B


                                ?


|   (OS: Operating Systems) |           (Memory Management) | 29
Contiguous Allocation (cont.)
                                           Multiple-partition allocation
                  Hole –

    


       OS
        a)                        allocated partitions
        b)               free partitions hole)
        OS                         OS                    OS                          OS

    process 5                  process 5              process 5                   process 5
                                                      process 9                   process 9

    process 8                                                                     process 10


    process 2                  process 2              process 2                   process 2


    |           (OS: Operating Systems) |              (Memory Management) | 30
Fragmentation
                                      Multiple Partition
       2
           Internal Fragmentation                      Fixed Sized)
           External Fragmentation                      Dynamic)


                            Fix Sized                                          Dynamic
                                                              P1


                                                              P2



                          Internal Fragment

                                                                   External Fragment
    |           (OS: Operating Systems) |           (Memory Management) | 31
Fragmentation
                                    External Fragmentation
    


                                   Internal Fragmentation
    



                     compaction
    


    




    |   (OS: Operating Systems) |         (Memory Management) | 32
Compaction
                                   Dynamic Allocation

                                   External Fragmentation

                                     External Fragmentation




                                                                        Copy




    |   (OS: Operating Systems) |            (Memory Management) | 33
Dynamic Storage-Allocation Problem
                                                                      n
                                      First-fit:                              (first hole)

                                      Best-fit:
                                              smallest hole            (
                  )
                                           Worst-fit:
                                                         largest hole (
                                 )

        First-Fit                Best-Fit                     Worst-Fit



    |      (OS: Operating Systems) |                (Memory Management) | 34
First Fit

                                                     20K

   Scan
                                                            First


          Fragment




    |        (OS: Operating Systems) |         (Memory Management) | 35
Best-Fit

       Scan                                       20K

                                                                          28K


                                                              Best


   Fragment                                                               23K
           Compact




    |          (OS: Operating Systems) |        (Memory Management) | 36
Worst-fit

                                                  20K
       Scan

                                                                            10K

                                                          Worst



                                                                           28K

          Fragment


                                                                            5K



    |          (OS: Operating Systems) |         (Memory Management) | 37
Paging





                   (paging)



                                           (physical memory)

    (frame)
                                         (logical memory)
                                             (page)

      |       (OS: Operating Systems) |         (Memory Management) | 38
Paging
 
                                   n page                                n
                        page table                                              physical
     addresses
           Internal fragmentation


                                                                                     0
                                                                                        1
            0
                                                                                        2 Frames
    3       1
Pages


                 Process                     Page
                                                                               Memory

        |        (OS: Operating Systems) |          (Memory Management) | 39
Address Translation Scheme

    (page number (p))                                                 (page
    offset (d))

                          Page number (p) –
             (page table)
                 (base address)


                               Page offset (d) –
                                                         physical memory
         address



     |        (OS: Operating Systems) |        (Memory Management) | 40
Address Translation Architecture




|   (OS: Operating Systems) |   (Memory Management) | 41
Paging Example




|   (OS: Operating Systems) |    (Memory Management) | 42
Paging Example




                                32                          4

|   (OS: Operating Systems) |    (Memory Management) | 43
Free Frames




       Before allocation                           After allocation


|   (OS: Operating Systems) |          (Memory Management) | 44
Address
                             (Physical Address)
                                      p : d (Page : offset)
 Page =                        Page, offset =
    Page                              page




    0


    1
                                                                  Page 1
                                       1 : 30
                                                                     Page    30
    2




                                                                                  -->
    |      (OS: Operating Systems) |              (Memory Management) | 45
Page Table




                        Page
        Frame
                                                            Page No. Frame No.
                                         0
                                                            0           4
               Page2                     1
                                                            1           5
                                         2
                                                            2           1
                 Page0                   4

                 Page1                   5


    |   (OS: Operating Systems) |            (Memory Management) | 46
 MMU                           Physical Address                         CPU
        Frame No.                                    offset
       Frame No.                       Add.                  Frame



                                                                        Real Addr.
    CPU        p        d                                 f      d
                                                                                     Memory

                               page        frame
                                    0          4
                                    1          5
                                    2          1



    |       (OS: Operating Systems) |              (Memory Management) | 47
(Shared Pages)
                                        (Pages)
                           (Function)
         Page


                  code1                           code1
code1
                  code2                           code2
code2
                                                                     Memory
                                                  data1
data1              data2


                                                  data2
 P1                 P2
                                                                       2



      |     (OS: Operating Systems) |     (Memory Management) | 48
(Segmentation)
                                   Segment
       Segment


                                             main program
                                      segment                         section

                                      (Load on demand)




    |   (OS: Operating Systems) |          (Memory Management) | 49
(Segmentation)



                        Segment
       Segment


                  main program,
                  procedure,
                  function,
                  method,
                  object,
                  local variables, global variables,
                  common block,
                  stack,
                  symbol table, arrays
    |       (OS: Operating Systems) |        (Memory Management) | 50
User’s View of a Program


                                         main program
                                  segment                       section

                                  (Load on demand)




|     (OS: Operating Systems) |      (Memory Management) | 51
Logical View of Segmentation
                                                 1

                                                 4
         1

                             2


     3                                           2
                           4

                                                 3




     user space                  physical memory space



 |   (OS: Operating Systems) |   (Memory Management) | 52
Segmentation Architecture

    <segment-number, offset>,
 Segment table –


                  base –

                    limit –                 segment.
 Segment-table base register (STBR)


 Segment-table length register (STLR)


    segment number s is legal if s < STLR.


    |       (OS: Operating Systems) |   (Memory Management) | 53
Segmentation Architecture
            (Cont.)
                           Relocation
           dynamic
           by segment table

                                    Sharing
           shared segments
           same segment number

                       Allocation
           first fit/best fit
           external fragmentation

    |            (OS: Operating Systems) |     (Memory Management) | 54
Segmentation Architecture
            (Cont.)
                                             2                                  (s),   (2)
                                            (d)


                        d                        0
       d

           d                                                          d


                  (base-limit)




    |           (OS: Operating Systems) |             (Memory Management) | 55
Segmentation Hardware




|    (OS: Operating Systems) |   (Memory Management) | 56
Implementation of Page Table
 Page table
 Page-table base register (PTBR)                             page table
 Page-table length register (PRLR)
    page table



                       page table


    associative memory                  translation look-aside
    buffers (TLBs)


     |      (OS: Operating Systems) |      (Memory Management) | 57
Associative Memory



                                   Page #       Frame #




    Address translation (A´, A´´)
        A´                                        frame#
                         frame #           page table




    |         (OS: Operating Systems) |          (Memory Management) | 58
Paging Hardware With TLB




|   (OS: Operating Systems) |   (Memory Management) | 59
Effective Access Time
 Associative Lookup =                  time unit
 Assume memory cycle time is 1 microsecond
 Hit ratio – percentage of times that a page number is found
   in the associative registers; ration related to number of
   associative registers
 Hit ratio =
 Effective Access Time (EAT)
                         EAT = (1 + )               + (2 + )(1 – )
                                  =2+         –




   |        (OS: Operating Systems) |                 (Memory Management) | 60
Memory Protection


                      associating protection bit


 Valid-invalid bit                                                    page table
           “valid”

           “invalid”




    |           (OS: Operating Systems) |   (Memory Management) | 61
Valid (v) or Invalid (i) Bit In A
          Page Table




|   (OS: Operating Systems) |   (Memory Management) | 62
Page Table Structure


                                      Hierarchical Paging
                                   Hashed Page Tables
                                   Inverted Page Tables




    |   (OS: Operating Systems) |           (Memory Management) | 63
Hierarchical Page Tables


        multiple page tables


                                                          two-level
    page table




    |         (OS: Operating Systems) |   (Memory Management) | 64
Two-Level Paging Example
                              4K page size                         )
       a page number                         20 bits
       a page offset                       12 bits
        page table                         page number
       a 10-bit page number
       a 10-bit page offset


                              page number               page offset
                                     pi         p2          d

                                      10        10             12

           pi                        page table            ,        p2
            page table



    |           (OS: Operating Systems) |                 (Memory Management) | 65
Two-Level Page-Table Scheme




|   (OS: Operating Systems) |   (Memory Management) | 66
Address-Translation Scheme
                                                                    two-
    level 32-bit




    |         (OS: Operating Systems) |   (Memory Management) | 67
Hashed Page Tables

                                       bits


                                                                  page table
    page table








    |       (OS: Operating Systems) |          (Memory Management) | 68
Hashed Page Table




|   (OS: Operating Systems) |   (Memory Management) | 69
Inverted Page Table






    page table








|   (OS: Operating Systems) |   (Memory Management) | 70
Inverted Page Table
       Architecture




|   (OS: Operating Systems) |   (Memory Management) | 71
Shared Pages
 Shared code
          One copy of read-only (reentrant) code shared among
           processes (i.e., text editors, compilers, window systems).
          Shared code must appear in same location in the logical
           address space of all processes

 Private code and data
          Each process keeps a separate copy of the code and data
          The pages for the private code and data can appear
           anywhere in the logical address space




   |            (OS: Operating Systems) |    (Memory Management) | 72
Shared Pages Example




|    (OS: Operating Systems) |   (Memory Management) | 73
Segmentation
 Memory-management scheme that supports user view of memory
 A program is a collection of segments. A segment is a logical unit
   such as:
                      main program,
                      procedure,
                      function,
                      method,
                      object,
                      local variables, global variables,
                      common block,
                      stack,
                      symbol table, arrays




   |          (OS: Operating Systems) |       (Memory Management) | 74
User’s View of a Program




|     (OS: Operating Systems) |   (Memory Management) | 75
Logical View of Segmentation
                                                 1

                                                 4
         1

                             2


     3                                           2
                           4

                                                 3




     user space                  physical memory space



 |   (OS: Operating Systems) |   (Memory Management) | 76
Example of Segmentation




|     (OS: Operating Systems) |   (Memory Management) | 77
Sharing of Segments




|   (OS: Operating Systems) |   (Memory Management) | 78
Segmentation with Paging –
               MULTICS
 The MULTICS system solved problems of external
   fragmentation and lengthy search times by paging the
   segments

 Solution differs from pure segmentation in that the
   segment-table entry contains not the base address of
   the segment, but rather the base address of a page
   table for this segment




   |        (OS: Operating Systems) |   (Memory Management) | 79
MULTICS Address Translation
         Scheme




|   (OS: Operating Systems) |   (Memory Management) | 80
Segmentation with Paging –
          Intel 386
 As shown in the following diagram, the Intel 386 uses
   segmentation with paging for memory management with a
   two-level paging scheme




   |        (OS: Operating Systems) |   (Memory Management) | 81
Intel 30386 Address
        Translation




|   (OS: Operating Systems) |   (Memory Management) | 82
Linux on Intel 80x86
 Uses minimal segmentation to keep memory management
  implementation more portable
 Uses 6 segments:
        Kernel code
        Kernel data
        User code (shared by all user processes, using logical
         addresses)
        User data (likewise shared)
     Task-state (per-process hardware context)
       
    LDT
 Uses 2 protection levels:
    Kernel mode
    User mode




   |           (OS: Operating Systems) |   (Memory Management) | 83
End of Chapter 8
|   (OS: Operating Systems) |   (Memory Management) | 85

Contenu connexe

Tendances

Chapter 08
Chapter 08Chapter 08
Chapter 08 Google
 
User level view of os
User level view of osUser level view of os
User level view of osMohd Arif
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case StudyGRamya Bharathi
 
multi processors
multi processorsmulti processors
multi processorsAcad
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisationwangyuanyi
 
Swap space management and protection in os
Swap space management and protection  in osSwap space management and protection  in os
Swap space management and protection in osrajshreemuthiah
 
Multi Processors And Multi Computers
 Multi Processors And Multi Computers Multi Processors And Multi Computers
Multi Processors And Multi ComputersNemwos
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernelguest547d74
 
Computer architecture multi processor
Computer architecture multi processorComputer architecture multi processor
Computer architecture multi processorMazin Alwaaly
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)vani261
 
Swap-space Management
Swap-space ManagementSwap-space Management
Swap-space ManagementAgnas Jasmine
 
Ch11 - Silberschatz
Ch11 - SilberschatzCh11 - Silberschatz
Ch11 - SilberschatzMarcus Braga
 

Tendances (20)

Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Disk Management
Disk ManagementDisk Management
Disk Management
 
Unixfs
UnixfsUnixfs
Unixfs
 
Memory management in linux
Memory management in linuxMemory management in linux
Memory management in linux
 
User level view of os
User level view of osUser level view of os
User level view of os
 
I/O System and Case Study
I/O System and Case StudyI/O System and Case Study
I/O System and Case Study
 
multi processors
multi processorsmulti processors
multi processors
 
Os
OsOs
Os
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
 
Swap space management and protection in os
Swap space management and protection  in osSwap space management and protection  in os
Swap space management and protection in os
 
Multi Processors And Multi Computers
 Multi Processors And Multi Computers Multi Processors And Multi Computers
Multi Processors And Multi Computers
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 
Computer architecture multi processor
Computer architecture multi processorComputer architecture multi processor
Computer architecture multi processor
 
Multi processor
Multi processorMulti processor
Multi processor
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
 
Swap-space Management
Swap-space ManagementSwap-space Management
Swap-space Management
 
Massstorage
MassstorageMassstorage
Massstorage
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Linux memory
Linux memoryLinux memory
Linux memory
 
Ch11 - Silberschatz
Ch11 - SilberschatzCh11 - Silberschatz
Ch11 - Silberschatz
 

En vedette

สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้
สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้
สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้panisa thepthawat
 
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการkanlayarat
 
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
Power BI Desktop screen tour in Thai
Power BI Desktop screen tour in ThaiPower BI Desktop screen tour in Thai
Power BI Desktop screen tour in ThaiPanaEk Warawit
 
4 ca-process structure
4 ca-process structure4 ca-process structure
4 ca-process structurekrissapat
 
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้Natcha Wannakot
 
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้panisa thepthawat
 

En vedette (11)

สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้
สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้
สิ่งแวดล้อมทางการเรียนรู้ กับ กระบวนทัศน์ใหม่ของการเรียนรู้
 
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
10 ca-mass-storage system structure (wichet p.'s conflicted copy 2012-12-17)
 
Ict
IctIct
Ict
 
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ
1 ระบบคอมพิวเตอร์และระบบปฏิบัติการ
 
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
9 ca-io systems structure (wichet p.'s conflicted copy 2012-12-17)
 
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
 
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
1 ca-cpu structure (wichet p.'s conflicted copy 2012-12-17)
 
Power BI Desktop screen tour in Thai
Power BI Desktop screen tour in ThaiPower BI Desktop screen tour in Thai
Power BI Desktop screen tour in Thai
 
4 ca-process structure
4 ca-process structure4 ca-process structure
4 ca-process structure
 
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อและเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
 
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
บทที่ 3 การออกแบบและพัฒนานวัตกรรม สื่อ และเทคโนโลยีสารสนเทศเพื่อการเรียนรู้
 

Similaire à 5 ca-memory structuret

8 1-os file system implementation
8 1-os file system implementation8 1-os file system implementation
8 1-os file system implementationGol D Roger
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07anishamca
 
Operating Systems Presentation
Operating Systems Presentation Operating Systems Presentation
Operating Systems Presentation Mayank Thanki
 
8 0-os file-system management
8 0-os file-system management8 0-os file-system management
8 0-os file-system managementGol D Roger
 
Cache-partitioning
Cache-partitioningCache-partitioning
Cache-partitioningdavidkftam
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07ainfara
 
บทที่ 3 โครงสร้างของระบบปฏิบัติการ
บทที่ 3 โครงสร้างของระบบปฏิบัติการบทที่ 3 โครงสร้างของระบบปฏิบัติการ
บทที่ 3 โครงสร้างของระบบปฏิบัติการChamp Phinning
 
MIPS Assembly Language I
MIPS Assembly Language IMIPS Assembly Language I
MIPS Assembly Language ILiEdo
 
A Survey on in-a-box parallel computing and its implications on system softwa...
A Survey on in-a-box parallel computing and its implications on system softwa...A Survey on in-a-box parallel computing and its implications on system softwa...
A Survey on in-a-box parallel computing and its implications on system softwa...ChangWoo Min
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07RajniKashyap9
 
Sql Server 2005 Memory Internals
Sql Server 2005 Memory InternalsSql Server 2005 Memory Internals
Sql Server 2005 Memory InternalsDmitry Geyzersky
 
Dsmp Whitepaper Release 3
Dsmp Whitepaper Release 3Dsmp Whitepaper Release 3
Dsmp Whitepaper Release 3gelfstrom
 
Operating systems for class 9th class
Operating systems for class 9th classOperating systems for class 9th class
Operating systems for class 9th classAnkit Kumar
 

Similaire à 5 ca-memory structuret (20)

8 1-os file system implementation
8 1-os file system implementation8 1-os file system implementation
8 1-os file system implementation
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07
 
Operating Systems Presentation
Operating Systems Presentation Operating Systems Presentation
Operating Systems Presentation
 
8 0-os file-system management
8 0-os file-system management8 0-os file-system management
8 0-os file-system management
 
Cache-partitioning
Cache-partitioningCache-partitioning
Cache-partitioning
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07
 
บทที่ 3 โครงสร้างของระบบปฏิบัติการ
บทที่ 3 โครงสร้างของระบบปฏิบัติการบทที่ 3 โครงสร้างของระบบปฏิบัติการ
บทที่ 3 โครงสร้างของระบบปฏิบัติการ
 
Wolfgang Lehner Technische Universitat Dresden
Wolfgang Lehner Technische Universitat DresdenWolfgang Lehner Technische Universitat Dresden
Wolfgang Lehner Technische Universitat Dresden
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Operating systems
Operating systemsOperating systems
Operating systems
 
MIPS Assembly Language I
MIPS Assembly Language IMIPS Assembly Language I
MIPS Assembly Language I
 
Genode Architecture
Genode ArchitectureGenode Architecture
Genode Architecture
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
A Survey on in-a-box parallel computing and its implications on system softwa...
A Survey on in-a-box parallel computing and its implications on system softwa...A Survey on in-a-box parallel computing and its implications on system softwa...
A Survey on in-a-box parallel computing and its implications on system softwa...
 
Operating systems11 9-07
Operating systems11 9-07Operating systems11 9-07
Operating systems11 9-07
 
Sql Server 2005 Memory Internals
Sql Server 2005 Memory InternalsSql Server 2005 Memory Internals
Sql Server 2005 Memory Internals
 
Lect01
Lect01Lect01
Lect01
 
Dsmp Whitepaper Release 3
Dsmp Whitepaper Release 3Dsmp Whitepaper Release 3
Dsmp Whitepaper Release 3
 
virtual memory - Computer operating system
virtual memory - Computer operating systemvirtual memory - Computer operating system
virtual memory - Computer operating system
 
Operating systems for class 9th class
Operating systems for class 9th classOperating systems for class 9th class
Operating systems for class 9th class
 

Plus de krissapat

8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)krissapat
 
7 ca-file-system management
7 ca-file-system management7 ca-file-system management
7 ca-file-system managementkrissapat
 
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)krissapat
 
3 ca-computer system structure
3 ca-computer system structure3 ca-computer system structure
3 ca-computer system structurekrissapat
 
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)krissapat
 

Plus de krissapat (6)

8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
8 ca-file system implementation (wichet p.'s conflicted copy 2012-12-17)
 
7 ca-file-system management
7 ca-file-system management7 ca-file-system management
7 ca-file-system management
 
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
 
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
6 ca-virtual memory structure (wichet p.'s conflicted copy 2012-12-17)
 
3 ca-computer system structure
3 ca-computer system structure3 ca-computer system structure
3 ca-computer system structure
 
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
2 ca-computer systems (wichet p.'s conflicted copy 2012-12-18)
 

5 ca-memory structuret

  • 1. Memory Management Structure
  • 2. Learning Objectives    | (OS: Operating Systems) | (Memory Management) | 2
  • 3. Agenda  (Background)  (Swapping)  (Contiguous Allocation)  (Paging)  (Segmentation)  (Segmentation with Paging) | (OS: Operating Systems) | (Memory Management) | 3
  • 4. Background  (instruction-execution cycle)  (fetch)  decode 1  execution 2  (store) | (OS: Operating Systems) | (Memory Management) | 4
  • 5. Background (2)  (machine code)  Input queue    | (OS: Operating Systems) | (Memory Management) | 5
  • 6. Background (3) 6.1 | (OS: Operating Systems) | (Memory Management) | 6
  • 7. Background (3)  (run)   Compile time  (absolute address)  Load time  (relocatable)  Execution time   (run time) (e.g., base and limit registers) | (OS: Operating Systems) | (Memory Management) | 7
  • 8. 6.2 | (OS: Operating Systems) | (Memory Management) | 8
  • 9. Logical vs. Physical Address Space   Logical address  (virtual address)  Physical address  (memory-address register)   (logical address space)  (physical address space) | (OS: Operating Systems) | (Memory Management) | 9
  • 10. Memory-Management Unit (MMU)  Logical Address Physical Address Relocation  MMU  (relocate register)  logical addresses MMU real physical | (OS: Operating Systems) | (Memory Management) | 10
  • 11. Dynamic relocation using a relocation register | (OS: Operating Systems) | (Memory Management) | 11
  • 12. Dynamic Loading   dynamic loading) relative memory  (routine)   (library routine) | (OS: Operating Systems) | (Memory Management) | 12
  • 13. Dynamic Linking  OS (static linking)  execution time  (stub)  stub  routine library (shared libraries) | (OS: Operating Systems) | (Memory Management) | 13
  • 14.  Static Linked Library (Link  EXE  Dynamic Linked Library (Link  EXE DLL  DLL DOS Static linked | (OS: Operating Systems) | (Memory Management) | 14
  • 15.    Overlay  Swapping  Single Partition Allocation  Multiple Partition Allocation | (OS: Operating Systems) | (Memory Management) | 15
  • 16. Overlay   (overlay)  | (OS: Operating Systems) | (Memory Management) | 16
  • 17. Overlay  Compiler Assemble    (Overlay) | (OS: Operating Systems) | (Memory Management) | 17
  • 18. | (OS: Operating Systems) | (Memory Management) | 18
  • 19. Swapping  (swap) (virtual Memory)  Backing store  - direct access  Roll out, roll in  (priority base)   | (OS: Operating Systems) | (Memory Management) | 19
  • 20. Schematic View of Swapping 6.5 | (OS: Operating Systems) | (Memory Management) | 20
  • 21. (Single Partition Allocation)  2  System  User   Batch system) DOS USER OS | (OS: Operating Systems) | (Memory Management) | 21
  • 22. User Area) System  Process1 Error OS | (OS: Operating Systems) | (Memory Management) | 22
  • 23. Contiguous Allocation   Resident OS), interrupt vector   OS (transient) | (OS: Operating Systems) | (Memory Management) | 23
  • 24. Contiguous Allocation   Resident OS), interrupt vector   OS (transient)  (fixed-size partition) Single-partition allocation  Relocation-register scheme OS  base register Offset  limit register | (OS: Operating Systems) | (Memory Management) | 24
  • 25. Base register limit register | (OS: Operating Systems) | (Memory Management) | 25
  • 26. | (OS: Operating Systems) | (Memory Management) | 26
  • 27. (Multiple Partition Allocation)  Single Partition  2  Fixed Sized Partition Partition  Dynamic Allocation Partition | (OS: Operating Systems) | (Memory Management) | 27
  • 28. Fix Sized Partition 500B 1000B 2 Partition 2100B 3 Partition ? | (OS: Operating Systems) | (Memory Management) | 28
  • 29. Fix Sized Partition 1200B 1200B 2580B 2580B ? | (OS: Operating Systems) | (Memory Management) | 29
  • 30. Contiguous Allocation (cont.)  Multiple-partition allocation  Hole –   OS a) allocated partitions b) free partitions hole) OS OS OS OS process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 10 process 2 process 2 process 2 process 2 | (OS: Operating Systems) | (Memory Management) | 30
  • 31. Fragmentation  Multiple Partition  2  Internal Fragmentation Fixed Sized)  External Fragmentation Dynamic) Fix Sized Dynamic P1 P2 Internal Fragment External Fragment | (OS: Operating Systems) | (Memory Management) | 31
  • 32. Fragmentation  External Fragmentation   Internal Fragmentation   compaction   | (OS: Operating Systems) | (Memory Management) | 32
  • 33. Compaction  Dynamic Allocation  External Fragmentation  External Fragmentation Copy | (OS: Operating Systems) | (Memory Management) | 33
  • 34. Dynamic Storage-Allocation Problem n  First-fit: (first hole)  Best-fit: smallest hole ( )  Worst-fit: largest hole ( ) First-Fit Best-Fit Worst-Fit | (OS: Operating Systems) | (Memory Management) | 34
  • 35. First Fit 20K   Scan First    Fragment | (OS: Operating Systems) | (Memory Management) | 35
  • 36. Best-Fit  Scan 20K  28K  Best   Fragment 23K Compact | (OS: Operating Systems) | (Memory Management) | 36
  • 37. Worst-fit 20K  Scan  10K  Worst  28K  Fragment 5K | (OS: Operating Systems) | (Memory Management) | 37
  • 38. Paging   (paging)  (physical memory) (frame)  (logical memory) (page) | (OS: Operating Systems) | (Memory Management) | 38
  • 39. Paging   n page n  page table physical addresses  Internal fragmentation 0 1 0 2 Frames 3 1 Pages Process Page Memory | (OS: Operating Systems) | (Memory Management) | 39
  • 40. Address Translation Scheme  (page number (p)) (page offset (d))  Page number (p) – (page table) (base address)  Page offset (d) – physical memory address | (OS: Operating Systems) | (Memory Management) | 40
  • 41. Address Translation Architecture | (OS: Operating Systems) | (Memory Management) | 41
  • 42. Paging Example | (OS: Operating Systems) | (Memory Management) | 42
  • 43. Paging Example 32 4 | (OS: Operating Systems) | (Memory Management) | 43
  • 44. Free Frames Before allocation After allocation | (OS: Operating Systems) | (Memory Management) | 44
  • 45. Address (Physical Address)  p : d (Page : offset)  Page = Page, offset = Page page 0 1 Page 1 1 : 30 Page 30 2 --> | (OS: Operating Systems) | (Memory Management) | 45
  • 46. Page Table   Page Frame Page No. Frame No. 0 0 4 Page2 1 1 5 2 2 1 Page0 4 Page1 5 | (OS: Operating Systems) | (Memory Management) | 46
  • 47.  MMU Physical Address CPU  Frame No. offset  Frame No. Add. Frame Real Addr. CPU p d f d Memory page frame 0 4 1 5 2 1 | (OS: Operating Systems) | (Memory Management) | 47
  • 48. (Shared Pages)  (Pages)  (Function)  Page code1 code1 code1 code2 code2 code2 Memory data1 data1 data2 data2 P1 P2 2 | (OS: Operating Systems) | (Memory Management) | 48
  • 49. (Segmentation)  Segment  Segment main program segment section (Load on demand) | (OS: Operating Systems) | (Memory Management) | 49
  • 50. (Segmentation)   Segment  Segment  main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, arrays | (OS: Operating Systems) | (Memory Management) | 50
  • 51. User’s View of a Program main program segment section (Load on demand) | (OS: Operating Systems) | (Memory Management) | 51
  • 52. Logical View of Segmentation 1 4 1 2 3 2 4 3 user space physical memory space | (OS: Operating Systems) | (Memory Management) | 52
  • 53. Segmentation Architecture  <segment-number, offset>,  Segment table –  base –  limit – segment.  Segment-table base register (STBR)  Segment-table length register (STLR) segment number s is legal if s < STLR. | (OS: Operating Systems) | (Memory Management) | 53
  • 54. Segmentation Architecture (Cont.)  Relocation  dynamic  by segment table  Sharing  shared segments  same segment number  Allocation  first fit/best fit  external fragmentation | (OS: Operating Systems) | (Memory Management) | 54
  • 55. Segmentation Architecture (Cont.)  2 (s), (2) (d)   d 0  d  d d  (base-limit) | (OS: Operating Systems) | (Memory Management) | 55
  • 56. Segmentation Hardware | (OS: Operating Systems) | (Memory Management) | 56
  • 57. Implementation of Page Table  Page table  Page-table base register (PTBR) page table  Page-table length register (PRLR) page table   page table  associative memory translation look-aside buffers (TLBs) | (OS: Operating Systems) | (Memory Management) | 57
  • 58. Associative Memory  Page # Frame # Address translation (A´, A´´)  A´ frame#  frame # page table | (OS: Operating Systems) | (Memory Management) | 58
  • 59. Paging Hardware With TLB | (OS: Operating Systems) | (Memory Management) | 59
  • 60. Effective Access Time  Associative Lookup = time unit  Assume memory cycle time is 1 microsecond  Hit ratio – percentage of times that a page number is found in the associative registers; ration related to number of associative registers  Hit ratio =  Effective Access Time (EAT) EAT = (1 + ) + (2 + )(1 – ) =2+ – | (OS: Operating Systems) | (Memory Management) | 60
  • 61. Memory Protection  associating protection bit  Valid-invalid bit page table  “valid”  “invalid” | (OS: Operating Systems) | (Memory Management) | 61
  • 62. Valid (v) or Invalid (i) Bit In A Page Table | (OS: Operating Systems) | (Memory Management) | 62
  • 63. Page Table Structure  Hierarchical Paging  Hashed Page Tables  Inverted Page Tables | (OS: Operating Systems) | (Memory Management) | 63
  • 64. Hierarchical Page Tables  multiple page tables  two-level page table | (OS: Operating Systems) | (Memory Management) | 64
  • 65. Two-Level Paging Example  4K page size )  a page number 20 bits  a page offset 12 bits  page table page number  a 10-bit page number  a 10-bit page offset  page number page offset pi p2 d 10 10 12 pi page table , p2 page table | (OS: Operating Systems) | (Memory Management) | 65
  • 66. Two-Level Page-Table Scheme | (OS: Operating Systems) | (Memory Management) | 66
  • 67. Address-Translation Scheme  two- level 32-bit | (OS: Operating Systems) | (Memory Management) | 67
  • 68. Hashed Page Tables  bits  page table page table  | (OS: Operating Systems) | (Memory Management) | 68
  • 69. Hashed Page Table | (OS: Operating Systems) | (Memory Management) | 69
  • 70. Inverted Page Table    page table  | (OS: Operating Systems) | (Memory Management) | 70
  • 71. Inverted Page Table Architecture | (OS: Operating Systems) | (Memory Management) | 71
  • 72. Shared Pages  Shared code  One copy of read-only (reentrant) code shared among processes (i.e., text editors, compilers, window systems).  Shared code must appear in same location in the logical address space of all processes  Private code and data  Each process keeps a separate copy of the code and data  The pages for the private code and data can appear anywhere in the logical address space | (OS: Operating Systems) | (Memory Management) | 72
  • 73. Shared Pages Example | (OS: Operating Systems) | (Memory Management) | 73
  • 74. Segmentation  Memory-management scheme that supports user view of memory  A program is a collection of segments. A segment is a logical unit such as: main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, arrays | (OS: Operating Systems) | (Memory Management) | 74
  • 75. User’s View of a Program | (OS: Operating Systems) | (Memory Management) | 75
  • 76. Logical View of Segmentation 1 4 1 2 3 2 4 3 user space physical memory space | (OS: Operating Systems) | (Memory Management) | 76
  • 77. Example of Segmentation | (OS: Operating Systems) | (Memory Management) | 77
  • 78. Sharing of Segments | (OS: Operating Systems) | (Memory Management) | 78
  • 79. Segmentation with Paging – MULTICS  The MULTICS system solved problems of external fragmentation and lengthy search times by paging the segments  Solution differs from pure segmentation in that the segment-table entry contains not the base address of the segment, but rather the base address of a page table for this segment | (OS: Operating Systems) | (Memory Management) | 79
  • 80. MULTICS Address Translation Scheme | (OS: Operating Systems) | (Memory Management) | 80
  • 81. Segmentation with Paging – Intel 386  As shown in the following diagram, the Intel 386 uses segmentation with paging for memory management with a two-level paging scheme | (OS: Operating Systems) | (Memory Management) | 81
  • 82. Intel 30386 Address Translation | (OS: Operating Systems) | (Memory Management) | 82
  • 83. Linux on Intel 80x86  Uses minimal segmentation to keep memory management implementation more portable  Uses 6 segments:  Kernel code  Kernel data  User code (shared by all user processes, using logical addresses)  User data (likewise shared) Task-state (per-process hardware context)   LDT  Uses 2 protection levels:  Kernel mode  User mode | (OS: Operating Systems) | (Memory Management) | 83
  • 85. | (OS: Operating Systems) | (Memory Management) | 85