1 / 24

University College of Science Mohanlal Sukhadia University

University College of Science Mohanlal Sukhadia University. A presentation on : Memory management Presented By : Prithvipal Singh Ranawat, Punit Kumar, Punita Acharya. MEMORY MANAGEMENT. Memory management under Linux has two components:-

britannia
Download Presentation

University College of Science Mohanlal Sukhadia University

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. University College of ScienceMohanlalSukhadia University A presentation on : Memory management Presented By : Prithvipal Singh Ranawat, Punit Kumar, Punita Acharya

  2. MEMORY MANAGEMENT Memory management under Linux has two components:- Allocating and freeing physical memory: pages and small blocks of memory. The second handles virtual memory.

  3. Management Of Physical MemoryPAGE ALLOCATOR The primary physical- memory manager in the Linux kernel is the page allocator . Allocator is responsible for allocating or freeing all physical pages. Allocator uses a buddy-heap algorithm to keep track of available physical pages.

  4. BUDDY HEAP A buddy heap allocator pairs adjacent unit of allocatable memory. Two small freed allocated partner regions are combined to form a larger region. A larger free region will be subdivided into two partners to satisfy the request ,when small memory request can’t be satisfied by allocation of an existing small free region.

  5. SPLITTING OF MEMORY IN BUDDY HEAP 16 KB 8KB 8KB 8KB 4KB 4KB

  6. All memory allocation in the Linux kernel occur either Statically or Dynamically . Several specialized memory management subsystems use the underlying page allocator to manage their own pool of memory are :- VIRTUAL MEMORY SYSTEM. THE KMALLOC VARIABLE-LENGTH ALLOCATOR. THE KERNELS TWO PERSISTENT DATA CACH :- BUFFER CACHE. PAGE CACHE.

  7. KMALLOC It is analogous to the ‘C’ language’s malloc function. It is an additional allocator for arbitrary size request. Kmalloc service allocates entire page on demand ,but splits them into smaller piece.

  8. BUFFER CACHE It is the Kernel’s main cache for block-oriented devices. Buffer cache is the main mechanism through which I/O to these devices is performed.

  9. PAGE CACHE The native disk-based file system and the NFS network file system use the PAGE CACHE. It can cache the networked data.

  10. Virtual Memory • Creation of the pages. • Loading of the pages in to memory. • The virtual memory manager maintain two views : • A set of separate region • A set of the pages

  11. A set of separate region • It is a logical view, describing instructions that the VM system has received. • Each region is described by vm_area_struct, defines the property of region. • They are linked by Balanced Binary tree to allow fast searching.

  12. A set of the pages • This view is stored in the HW page tables. • It gives the current location of each page. • It is managed by the kernel’s software- interrupt handlers.

  13. Virtual Memory Region • Properties : • Backing store for the region. • Reaction to write. • Backing store for the region :- It describes that where the page come for a region.

  14. 2) Reaction to write :- • Mapping of region in process’s address space • It can be private or shared. If a process writes to a privately mapped region, than the pager detects that a copy-on-write is necessary to keep the changes local to the process. If a process writes to a shared region in updating of the object mapped into the region, so that the changes will be visible immediately to any other process that is mapping that object.

  15. Lifetime of a Virtual Address Space • Creation of a new virtual address space in two situations :- • Process runs a new program with exec( ). • On creation of a new process by the fork( ).

  16. 1. Process runs a new program withexec ( ). It is easy. When a prog. Is executed, the process is executed, the process is given a new, completely empty virtual address space. It is up to the routines for loading the prog. To populate the address space with virtual memory regions.

  17. 2. On creation of a new process by the fork ( ). It involves creating a complete copy of the existing process’s virtual address space. Kernel copies the parent process’s vm_area_struct, then creat a new set page table for child.rrr

  18. Swapping and Paging • Swapping :- It is a technique in which processes are swapped in or out of main memory to the disk. • Paging :- The paging system divided into tw section: • Policy Algorithm • Paging Mechanism

  19. Policy Algorithm :- It decides which pages to write out to disk and when to write them. • Paging Mechanism :- It carries out the transfer and pages data back into physical memory when they are needed again.

  20. Kernel Virtual Memory The page-table entire that map to these kernel pages are marked as protected, so the pages are not visible or modifiable when the processor is running in user mode.

  21. Execution & loading of user programs Triggered by exec() system call Verifying the permission right.

  22. No single routine in Linux for loading a new program. • Invokes a new program • Change in standard format for Linux binary files.

  23. Mapping of programs into memory Pages of file mapped into regions of virtual memory. Loader sets the initial memory mapping for the program to start. Pages loaded using demand paging. Example:- ELF format.

  24. Static & dynamic linking Static linking: not efficient Dynamic linking: more efficient.

More Related