Recents in Beach

Virtual Memory



Previous                                                 Next⏩


It is a technique which allows execution of process that may not be compiled within the primary memory.
It separates the user logical memory from the physical memory. This separation allows an extremely large memory to be provided for program when only a small physical memory is available.
Virtual memory makes the task of programming much easier because the programmer no longer needs to working about the amount of the physical memory is available or not.
The virtual memory allows files and memory to be shared by different processes by page sharing.
It is most commonly implemented by demand paging.


Demand Paging

                A demand paging system is similar to the paging system with swapping feature.
 When we want to execute a process we swap it into the memory. 
A swapper manipulates entire process where as a pager is concerned with the individual pages of a process. 
The demand paging concept is using pager rather than swapper. 
When a process is to be swapped in, the pager guesses which pages will be used before the process is swapped out again.
 Instead of swapping in a whole process, the pager brings only those necessary pages into memory. 
The transfer of a paged memory to contiguous disk space is shown in below figure.

                             
                           Thus it avoids reading into memory pages that will not used any way decreasing the swap time and the amount of physical memory needed. 
In this technique we need some hardware support to distinct between the pages that are in memory and those that are on the disk. 
A valid and invalid bit is used for this purpose.
When this bit is set to valid it indicates that the associate page is in memory. If the bit is set to invalid it indicates that the page is either not valid or is valid but currently not in the disk.


               Marking a page invalid will have no effect if the process never attempts to access that page. So while a process executes and access pages that are memory resident, execution proceeds normally. 
Access to a page marked invalid causes a page fault trap. It is the result of the OS’s failure to bring the desired page into memory.

Procedure to handle page fault

If a process refers to a page that is not in physical memory then
·  We check an internal table (page table) for this process to determine whether the reference was valid or invalid.
·  If the reference was invalid, we terminate the process, if it was valid but not yet brought in, we have to bring that from main memory.
·  Now we find a free frame in memory.
·  Then we read the desired page into the newly allocated frame.
·  When the disk read is complete, we modify the internal table to indicate that the page is now in memory.
·  We restart the instruction that was interrupted by the illegal address trap. Now the process can access the page as if it had always been in memory.

Advantages of Virtual Memory

  • Virtual memory helps to gain speed when only a particular segment of the program is required for the execution of the program.
  • It is very helpful in implementing a multiprogramming environment.
  • It allows you to run more applications at once.
  • It helps you to fit many large programs into smaller programs.
  • Common data or code may be shared between memory.
  • Process may become even larger than all of the physical memory.
  • Data / code should be read from disk whenever required.
  • The code can be placed anywhere in physical memory without requiring relocation.
  • More processes should be maintained in the main memory, which increases the effective use of CPU.
  • Each page is stored on a disk until it is required after that, it will be removed.
  • It allows more applications to be run at the same time.
  • There is no specific limit on the degree of multiprogramming.
  • Large programs should be written, as virtual address space available is more compared to physical memory.
Disadvantages of Virtual Memory
  • Applications may run slower if the system is using virtual memory.
  • Likely takes more time to switch between applications.
  • Offers lesser hard drive space for your use.
  • It reduces system stability.
  • It allows larger applications to run in systems that don't offer enough physical RAM alone to run them.
  • It doesn't offer the same performance as RAM.
  • It negatively affects the overall performance of a system.
  • Occupy the storage space, which may be used otherwise for long term data storage.
Summary:
  • Virtual Memory is a storage mechanism which offers user an illusion of having a very big main memory.
  • Virtual memory is needed whenever your computer doesn't have space in the physical memory
  • A demand paging mechanism is very much similar to a paging system with swapping where processes stored in the secondary memory and pages are loaded only on demand, not in advance.
  • Important Page replacement methods are 1) FIFO 2) Optimal Algorithm 3) LRU Page Replacement.
  • In FIFO (First-in-first-out) method, memory selects the page for a replacement that has been in the virtual address of the memory for the longest time.
  • The optimal page replacement method selects that page for a replacement for which the time to the next reference is the longest.
  • LRU method helps OS to find page usage over a short period of time.
  • Virtual memory helps to gain speed when only a particular segment of the program is required for the execution of the program.
  • Applications may run slower if the system is using virtual memory.

Previous                                                       Next⏩

  1. What is an Operating System ?
  2. Discuss the structure off OS ?
  3. Explain type of OS?
  4. Explain Function of OS?
  5. Explain OS Services ?
  6. What do mean by system call ?List different type ofsystem call available ?

  1. what is process ? and Characteristics ?
  2. What is different process state? explain the same in details?
  3. write short note on user level and kernal level threads?
  4. explain what is thread and its type ?
  5. explain scheduler ? (short term,medium term,and long term)
  6. state and explain scheduling criteria ?
  7. Explain scheduling algorithm ? [ FCFS,SJF,PRIORITY,ROUND ROBINE.]    

  1. What is process synchronization ? explain critical section problem and race condition ?
  2. what is Race Condition ?
  3. what is critical section problem?
  4. explain classical problem of synchronization?
  5. explain bounded - buffer problem?
  6. explain reader - writer problem ?
  7. explain Dining Philosophers Problem ?
  8. explain semaphores ? its type ?

  1.  What is deadlock ?
  2. What are the 4 condition to produce deadlock ?
  3. explain methods of handling deadlock ?
  4. explain in detail deadlock prevention ?
  5. write short note on deadlock avoidance ?
  6. explain deadlock detection ? 
  7. explain Banker algorithm with example ? 

Post a Comment

0 Comments