Memory Management Is A Term Computer Science Essay

Published:

The primary physical-memory manager in the Linux kernel is the page allocator. There is one allocator for each zone, responsible for allocating, freeing all physical pages for each zone, and capable of allocating ranges of physically contiguous pages on request, but even though some allocations may require a page from a particular zone, a normal allocation can come form zone_DMA or zone_NORMAL. However, it is preferable to use a page from the particular zone, mostly to save the DMA space, but if needed and memory is low, Kernel can use whichever zone is available and suitable.

Logical memory

Logical memory for a computer operating system has assigned more than one block of physical memory from the RAM memory for a process. In this case, the process will have more than one physical address, and it is a problem because in a situation where paging done. Therefore, the operating system make the logical memory block is a combination of the physical memory blocks, and logical memory block that contains the logical address assigned to the associated logical memory unit.

Lady using a tablet
Lady using a tablet

Professional

Essay Writers

Lady Using Tablet

Get your grade
or your money back

using our Essay Writing Service!

Essay Writing Service

Virtual Memory

The Virtual Memory management system is one of the most important part of an operating system. Since the beginning of the computer operations there has been a need for more memory than the exciting physical memory in a computer. To meet this need many strategies has been developed in the present. Virtual memory is their most successful method. Virtual memory makes the computer appear to have more memory than its actual physical memory.

Swap Space

Swap space is located on hard drives, which have a slower access time than physical memory. Swap space can be in the same partition of the hard disk, as a separate partition dedicated to it on the same disk, a dedicated partition on a second hard disk or even a combination of swap partition and swap file. Ubuntu has two forms of swap spaces, the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the file system that resides amongst your system and data files. It is recommended to allocate at least 2x capacity of the actual physical memory. Swap space is also used for system hibernation.

Swap Partition

The advantage of using swaps partitions, it can be used by two or more Linux based installations on the same PC. Example - dual boot or triple boot with a Windows based operating system. Also a Swap partition comes in handy when disk is full where the swap file could create incompletely. Swap partitions are faster than swap files, and they are commonly used in Linux systems.

Swap file

As well as the swap partition, Linux also supports a swap file that you can create, prepare, and mount in a fashion similar to that of a swap partition. The advantage of swap files is that you don't need to find an empty partition or repartition a disk to add additional swap space (Miller, R 2007, p.154). On the other hand swap files are good if you need to change the size of the swap memory regularly as it is easier to resize the swap file through whole partition.

Swap-In and Swap-Out

In Ubuntu, the swap space is used when all the physical memory on your computer is reserved by running processes yet an additional demand for memory resources exist. In such scenarios where the physical memory is at full capacity, the kernel allocates inactive pages in the physical memory to the swap space. (Kenny, J, p. 98) This creates additional space in the physical memory to meet the additional demand. When the pages that are in the swap space are needed by the physical memory again, they are swapped backed into the physical memory. These operations are called swapping out and swapping in, respectively.

Caches

1. Linux Swap Cache

Linux swap the cache saved only dirty pages. The unmodified image page will be deleted from the memory and modify page mobile switching cache, when the system physical memory and processes is low, then need to be loaded.

2. Hardware Cache

Lady using a tablet
Lady using a tablet

Comprehensive

Writing Services

Lady Using Tablet

Plagiarism-free
Always on Time

Marked to Standard

Order Now

As we have already discussed in previous article that a processor reads page table entries to convert virtual address to physical address. Usually a processor stores the information of page table entries in a hardware cache.

This hardware cache consists of Translational look-aside buffers or TLBs.

Whenever a processor needs to translate a virtual address, then it tries to fetch the page table entry information from TLBs. If it finds the entry then it proceeds further but if processor is not able to find any such entry then it tells the OS that a TLB miss has occurred and asks the OS to fix things up.

To deliver this information of TLB miss to OS, some kind of exception mechanism is used which is processor dependent. Now, the OS finds the correct entry and updates the TLB entry with it. When the exception is cleared (after OS fixes the problem) then the processor again tries to search the TLBs for the entry and this time it finds a valid entry.

3. Linux Buffer Cache

A buffer cache contains data buffers that the block device drivers use.

A block device driver is a one that operates on block of data i.e. it can be accessed by reading or writing fixed chunks or blocks of data.  A buffer cache is indexed. The device identifier is used for the indexing purpose.

The buffer cache makes the reading/writing very efficient and fast. For example consider a block device for example a hard disk. Reading/writing a hard disk requires file I/O which is quite expensive if we do it on hard disk each time a read or write is done. This buffer cache which sits in between, saves time as reads and write are done on this and rest is taken care by the cache.

Shared Virtual memory

When code is written then great care is taken by the developers that no piece of code is unnecessarily repeated. For example, functions are used in programs so that same piece of code can be called anytime from within the code.

A group of functions which can be commonly used are clubbed up into libraries. There-in comes the concept of shared memory which is once loaded into memory and can be used by multiple processes.

Virtual memory makes it easy for processes to share memory this is because the physical address are mapped through page tables and this is very much possible that same physical page frame number could be mapped in page table of multiple processes. This concept is known as shared virtual memory.

Demand Paging

In the previous sectioned we learned that if the processor goes to the processes page table with a virtual page frame number for which no entry was present in the table then two cases arise.

Either the process has tried to access an invalid memory address

The physical page corresponding to the virtual address was not loaded into physical memory

Out of the two cases above, the case 1 is the case where the process tries to memory address which it is not allowed. In this case a page fault is generated and the kernel terminates the process.

While in case '2′, as already explained, the physical page corresponding to the virtual address is not yet loaded into physical memory. In this case also a page fault is generated and the kernel then tries to bring the required memory page into physical memory from hard disk.

Since this operation of bringing a page from hard disk into physical memory is time consuming so by this time a context switch between processes happens and some other process is brought into execution. Meanwhile the page of the earlier process is brought into physical memory and the page tables are updated and then this process is brought back into execution again from the same instruction that caused the 'page fault'.

This is known as demand paging where all the memory pages corresponding to a process are not present in the physical memory at any given time. This saves the physical memory from clogging up with non-required memory pages while when necessary these pages can be brought into physical memory through  page fault (as explained above).

Lady using a tablet
Lady using a tablet

This Essay is

a Student's Work

Lady Using Tablet

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Examples of our work

or

Ubuntu use this technique to loading virtual pages into physical memory as they are accessed is known as demand paging. Ubuntu uses demand paging to load executable images into a process's virtual memory. Whenever a command is executed, the file containing it is opened and its contents are mapped into the process's virtual memory. This is done by modifying the data structures describing this process' memory map and is known as memory mapping.(Saheed. M, 2008) However, only the first part of the image is actually brought into physical memory. The rest of the image is left on disk. As the image executes, it generates page faults and Linux uses the process's memory map in order to determine which parts of the image to bring into memory for execution. ( L, Friedrich 2008)