Operating System11 - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Operating System11

Description:

Operating System(11) Minyi Guo. Dept. of Computer Science and Engineering, ... Most virtual memory use paging technology ... Processes access memory by virtual ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 27
Provided by: epccSj
Category:

less

Transcript and Presenter's Notes

Title: Operating System11


1
Operating System(11)
Minyi Guo Dept. of Computer Science and
Engineering, Shanghai Jiaotong University
2
Memory Management
  • Basic memory management
  • Swapping
  • Virtual memory
  • Page replacement algorithms
  • Implementation issues
  • Segmentation

3
Swapping
  • Memory allocation changes as
  • Processes come into memory
  • Processes leave memory
  • Take processes out from memory and bring process
    into memory are called Swapping

4
Swapping
5
Swapping
  • Problem with previous situation?
  • Difficult to grow process space
  • Solution
  • Allocating space for growing data segment
  • Allocating space for growing stack data segment

6
Swapping
7
Memory Mgmt Issues
  • Need keep track of memory used and available
  • Bit map approach
  • Linked list approach

8
Memory Mgmt
  • Divide memory into allocation units
  • Bit map approach Use one bit to mark if the unit
    is allocated or not
  • Linked list approach Use a linked list to
    indicate allocated and available units in chunks

9
Memory Mgmt
10
Memory Mgmt with Linked Lists
  • What happens when units are released?
  • May need to collapse linked list appropriately

11
Memory Mgmt with Linked Lists
12
Strategies to find a memory region
  • Best fit
  • Allocate the smallest memory region that can
    satisfy the request (least amount of wasted
    space)
  • First fit
  • Allocate the memory region that you find first
    that can satisfy the request

13
External Fragmentation
  • Processes come and go
  • Can leave a mishmash of available memory regions
  • Some regions may be too small to be of any use
  • Merging
  • Dynamical address translation

14
Virtual Memory
  • An address space can be larger than the amount of
    physical memory on the machine
  • Load part of the address space into the memory,
    and others stay in disk
  • Amount of the virtual memory?

15
Paging
  • Most virtual memory use paging technology
  • Allocate physical memory in terms of fixed-size
    chunks of memory, any free physical page frame
    can store any virtual page
  • Virtual address
  • virtual page number (high bits of address, e.g.
    bits 31-12 for 4 KB page)
  • offset (low bits of address, e.g. bits 11-0 for 4
    KB page)

16
Paging
17
Paging
  • Processes access memory by virtual addresses
  • Each virtual memory reference is translated into
    physical memory reference by the MMU

18
Paging
19
Paging
  • Page fault
  • The page is unmapped
  • Trap to kernel, then the OS allocate a free page
    frame and load the page to the memory. If there
    is no free page frame for this process, pick a
    little-used page frame and write its contents
    back to the disk

20
Page Table
  • Used to keep track of virtual-physical page map
  • One entry for each virtual page
  • Store the position of the page, and also keep
    information concerning other relevant information
    such read/write/execute, present, etc.
  • MMU use it to perform addresses translation

21
Paging
  • What must be changed on a context switch?
  • Page table, registers, cache image
  • Possibly memory images
  • Each virtual page can be in physical memory or
    disk

22
Paging
  • How does processor know that virtual page is not
    in physical memory?
  • Through a present/absent bit in page table
  • Pages can have different protections
  • e.g. read, write, execute
  • These information is also kept in page table

23
Page Table
Typical page table entry
24
The internal operation of the MMU with 16 4KB
pages
25
Pros of paging
  • simple memory allocation
  • can share lots of small pieces of an address
    space
  • easy to grow the address space
  • Simply add a virtual page to the page table and
    find a free physical page to hold the virtual
    page before accessing it

26
Cons of Paging
  • The size of page table could be enormous
  • Take 32 bits virtual address for example, assume
    the size of page is 4KB, then there are 65536
    virtual pages
  • For a 64 bit virtual address?
  • solution
  • Use multi-level translation
Write a Comment
User Comments (0)
About PowerShow.com