Header Ads

How virtual memory can be obtained by demand paging and segemtation

Virtual memory

It is a memory hierarchy which consists of a computer's memory and disk, that enables it to operate with only some part of its address space in the memory.


The logical memory is divided into pages whereas the physical memory is divided into frames. Page table is used to for mapping. The virtual memory is very much similar to the paging system but there is a difference that is, in virtual system paging is done with swapping. The operating system then checks that if the required page is available in the memory or not. If it is not then the required page will be swapped from the secondary memory. The virtual memory allows as many processes that is to be executed. It also enhances the efficiency of the CPU and also increases the multi-programming that can be implemented using paging.

Demand paging

Virtual memory can be implemented with the help of demand paging. Demand paging is like a paging system with swapping. This type of paging is dynamic in nature, where pages are swapped only when it is demanded. All the components and functions of the demand paging is as same as in virtual memory with a slight difference that the page table has 1 more entity that is known as present bit or valid-invalid bit. The valid-invalid bit can have value 0 or 1 that is used to indicate whether the required page is available or not. The value 0 indicates that the page is available whereas a 0 signifies that it is not present or currently not available.
Demand paging is the process of requesting a page in the physical memory on demand. The operating system checks for the availability of the page for further process. If the requested page is invalid that is, if it is not present in the physical memory then it is known as page fault. When the operating system encounters a page fault the whole process id terminated and the requested page is fetched form the secondary memory to the physical memory, after that the valid-invalid bit is set to 1 and the process is restarted again. In order to run a process, whole memory is not needed in the physical memory this is due to demand paging. Demand paging increases the CPU utilization, the degree of multi-programming and also allows more number of process execution.

Segmentation

Segmentation is the memory-management scheme that supports the user view of memory. A logical address space is a collection of segments, each segments has a name and a specific length . Hence the logical address consists of two tulpes and user has to specify both segment name and offset. Segmentation could be complex so for its simplicity, segments are numbered and are referred by them instead of segment name. A syntax of a logical address containing two tuple can be: <SegmentNumber,offset>.
When creating a segment one should keep following things in mind, a C compiler will create a separate segment for:
  • the code.
  • the global variables.
  • the heap of memory allocation.
  • the stacks used by thread.
  • the standard library.

No comments:

CSE Solved. Powered by Blogger.