Git Product home page Git Product logo

kernel_memory_management's People

Contributors

wangbojing avatar wenchao1024 avatar zzungs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kernel_memory_management's Issues

See here for more information about paging

Paging is a method of writing and reading data from a secondary storage(Drive) for use in primary storage(RAM). When a computer runs out of RAM, the operating system (OS) will move pages of memory over to the computer’s hard disk to free up RAM for other processes. This ensures that the operating system will never run out of memory and crash. Too much reliance on memory paging can impair performance, however, because random access memory operates much faster than disk memory. This means the operating system has to wait for the disk to catch up every time a page is swapped; the more a work.

How Does It Work?

img

img

The OS reads data from blocks called pages, all of which have identical size. In order to do so, the OS first needs to consult the page table which is used by virtual memory to store the mapping between virtual addresses and physical addresses. The physical part of the memory containing a single page is called a frame. When paging is used, a frame does not have to comprise a single physically contiguous region in storage. This approach offers an advantage over earlier memory management methods, because it facilitates more efficient and faster use of storage.

When a program tries to access a page that is not stored in RAM, the processor treats this action as a page fault. When this occurs the operating system must:

  1. Determine the location of the data on disk.
  2. Obtain an empty page frame in RAM to use as a container for the data.
  3. Load the requested data into the available page frame.
  4. Update the page table to refer to the new page frame.
  5. Return control to the program, transparently retrying the instruction that caused the page fault.

When all page frames are in use, the operating system must select a page frame to reuse for the page the program now needs. If the evicted page frame was dynamically allocated by a program to hold data, or if a program modified it since it was read into RAM, it must be written out to disk before being freed. If a program later references the evicted page, another page fault occurs and the page must be read back into RAM.

Pros:

By diving the memory into fix blocks, it eliminates the issue of External Fragmentation. It also supports Multiprogramming. Overheads that come with compaction during relocation are eliminated. Easy to swap since everything is the same size, which is usually the same size as disk blocks to and from which pages are swapped.

Cons:

Paging increases the price of computer hardware, as page addresses are mapped to hardware. Memory is forced to store variables like page tables. Some memory space stays unused when available blocks are not sufficient for address space for jobs to run. Since the physical memory is split into equal sizes, it allows for internal fragmentation.

How To Make Paging More Efficient

Every time the OS is translating from logical to physical, it requires a look up in the page table, which is stored in RAM. Meaning every process request would require two physical memory accesses. This issue greatly reduces the overall performance of our equipment.

In order to tackle this problem we use the Translation Lookaside Buffer(TLB). The TLB is a memory cache that stores recent translations of virtual memory to physical addresses for faster retrieval.

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.