Giter VIP home page Giter VIP logo

program-managed-virtual-heap's Introduction

How to run

  • Run make
  • Run ./test to get the test results, it may takes minutes to finish since lots of file I/O are involved.

Design

  • Page number mapping: The pm_map and vm_map keeps the mapping between virtual address and physical page number.
  • Memory allocation: The pm_malloc function allocates memory of a given size. It checks the free list for available memory blocks and, if necessary, allocates new memory in the heap or evicts memory to disk to make space.
  • Memory deallocation: The pm_free function deallocates memory at a given virtual address. It adds the freed memory block back to the free list and merges adjacent free blocks to reduce fragmentation.
  • Eviction and loading: The code uses a FIFO mechanism to transfer data between physical memory and disk when physical memory is exhausted. An evict_index is used to perform FIFO on memory. Everytime when there is a need to clear out memory, the page on evict_index will be popped out, and then evict_index is plused by 1. It also maintains a file pointer head and tail to track the pages to be evicted or loaded on disk.
  • Free list management: The allocator maintains a free list of available memory blocks. It tries to merge adjacent free blocks to reduce fragmentation.
  • Virtual memory: The code uses swap.data as a backup store for virtual memory. Also when communicating with the disk, the free list is managed with files in directory free_lists. It synchronize the free list deleting and recovering with page evicting and loading.

Thread-safty

  • In test.c 6 threads are created. Each thread allocates 5000 blocks of memory with randomized size. The each thread sleeps for some time and trys to set and get value. Finally all allocated memory got freed. Since only 2560 pages are stored in memory, virtual memory will be used.

program-managed-virtual-heap's People

Contributors

kylewang12 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.