Virtual Memory vs. Physical Memory

Abstract

Operating systems playing an important role to enable a set of processes to share the CPU time via scheduling of the CPU utilizations. With such processes executed in shared mode, the speed of the computer systems responses to its users and its performance are improved. That said, it is always required to keep such processes in memory for sharing the CPU time slice during the execution or waiting for other resources to be available, and as such various ways of memory management algorithms can be used to improve the performance of the memory allocation and de-allocation (Silberschatz and Galvin, 2009).

Silberschatz and Galvin (2009) explained that main memory and registers (built into CPU itself) are the only storage the CPU can access directly. However, due to the frequency difference between the CPU clock and the main memory, the processor normally needs to stall, since the data required to complete the instructions is not available. One of the solutions to the problem is to add fast memory (cash memory) to accommodate the speed differential between the CPU and the main memory. On the other hand, virtual memory is a technique that allow virtualizes the computer architecture (such as RAM, and disk storage) for processes to be executed in other area than main memory. With such technique, programs can be executed in the computer systems with larger capacity than the physical memory.

As well as it’s important that processes access the physical memory with relative good speed compared to the CPU speed; it’s imperative that each process should have a separate memory space. That said, operating systems should have the ability to determine the range of legal addresses that the process may access, and to ensure that the process can access only these legal addresses (Lysis, 2009).

Virtual Memory vs. Physical Memory

Silberschatz and Galvin (2009) explained that the instructions of any program must be executed in physical memory, and as such; it’s imperative that the entire logical address space is in physical memory. The following are the merits of physical memory:

Swapping – A process must be in main memory to be executed, and since the main memory is shared by many processes, a process can be swapped temporarily out of memory to a backing store (fast disk) to release memory to other process when it’s idle, and then bring it back into memory for execution. The total transfer time is directly proportional to the amount of memory swapped, and as such; this process can create a performance problem.

Protection – Since the main memory is shared by many processes, protection of memory space is required, and as such; the CPU hardware compares every address generated in the user mode with the registers. Any attempt by a program execution in the user mode to access operating-system memory or other user’s memory results in a trap to the operating system, which treats the attempt as a fatal error.

Fragmentation – Different allocation memory strategies such as first-fit and best-fit suffer from external fragmentation. As processes are loaded and removed from memory, the free memory space is broken into little pieces. External fragmentation exists when there is enough total memory space to satisfy a request but the available spaces are not contiguous.

Paging – Is a memory-management scheme that allows the physical address space for a process to be non-contiguous. Paging avoids fragmentation and the need of compaction.  Such scheme solves the problems with memory fitting of varying sizes onto the backing store where many systems were suffering from before the introduction of paging.

Multi-User & Single User Systems – Multi-user systems required a higher level of multiprogramming, and for a given set of processes, we can increase the multiprogramming level only by packing more processes into memory and as such; the reduction of memory waste (fragmentation) is required. The same rules are applied to the single-user environment; since users intend to run multi-programmes at the same time.

McNamara (2009) explained that virtual memory on the other hand; is a technique that allows the partial of the execution of processes to happen outside of the physical memory. The following are the merits of virtual memory:

  • One major advantage of such scheme is that programs can be larger than the physical memory. Virtual memory abstracts the physical memory with a large uniformed array of storage and as such; frees programmers from being concerns of memory limitations.
  • Virtual memory allows processes to share files and memory with two or more processes, and page sharing provides an efficient mechanism for process creating and that lead to the following benefits:
  1. System libraries can be shared by several processes through mapping of the shared objects into a virtual address space.
  2. Virtual memory enables processes to share memory and as such; communication between processes can be easily achieved.
  3. Virtual memory can allow pages to be shared during process creation.
  • Virtual memory in single and multi-users environment add a huge difference in multiprogramming and also, increase the performance of such environment since sharing processes, and enable such processes to be available for execution simultaneously where it increases the system speed, and multitasking capabilities.
  • Virtual memory allows the separation of logical memory from the physical memory and that can provide extremely large virtual memory when a smaller physical memory is available.

However, virtual memory can substantially decrease performance if the implementation of such technique were done carelessly (Silberschatz and Galvin, 2009).

Multi-User & Single User Systems – RAM represents within any computing system the amount of physical memory installed on personal computer and servers. It acts like short-term memory, enabling programs to load and operate faster. When user starts a program or an application, it uses a part of that memory. As more programs loaded to the physical memory, such as a Web browser or a word processor, it requires more memory, and the same scenario is exist on the server side with multi-users environment trying to access many applications on same the server. Operating systems make up the difference for that amount of RAM requirement by allocating or reserving a portion of the hard drive to act as part of the physical memory. Such extra allocated space is known as virtual memory, or page file. Such mechanism allow more programmes to be loaded at the same time, and also allow the multitasking and multi-programs to be managed in both single-user and multi-user environment (Walsh, 2000) . 

Finally, as the virtual memory is based on the disk I/O, it’s definitely slower than the physical memory. Also, it’s easy to be corrupted and being out of space since it’s controlled by the disk usage by users, and other programs (Loader, n.d.).

Conclusion

Walsh (2000) explained that usually a program resides on a disk as a binary executable file, and to be executed, the program must be brought into memory and placed within a process. According to the memory management in use, the process may be moved between disk and memory during its execution. As the process is executed, it accesses instructions and data from memory, and the process is terminated and its memory space is declared available.

Different techniques and strategies are used with the same goal; to keep many processes in memory simultaneously to allow multiprogramming. However; such strategies required that the entire process has to be in memory before execution. On the other hand; virtual memory technique allows the execution of process while it is not entirely within the physical memory. Such technique allows programs to be larger than the physical memory capacity and still can be executed by abstracting the physical memory into larger uniform array of storage. Finally; with virtual memory in place; programmers are free from worrying about memory availability in their program design, and in addition with virtual memory several processes can share system libraries and memory (Silberschatz and Galvin, 2009).

References

Lysis (2009) What Is the Difference Between Virtual Memory & Physical Memory? [Online]. Available from: http://www.ehow.com/facts_5704123_difference-virtual-memory-physical-memory_.html (Accessed: 29 August 2010).
Loader, S. (n.d.) Non Virtual Memory Systems: Advantages and disadvantages [Online]. Available from: http://www.surf.org.uk/articles/Non-Virtual-Memory-Systems.html (Accessed: 29 August 2010).

McNamara, T. (2009) Cache Vs. Virtual Memory [Online]. Available from: http://www.ehow.com/about_5374840_cache-vs-virtual-memory.html (Accessed: 29 August 2010).

Silberschatz, A. & Galvin, P. (2009) Operating System Concepts. 8th ed. NJ: John Wiley & Sons, Inc.

Walsh, L. (2000)  Virtual vs. physical swap & shared memory forks (sprocX)  [Online]. Available from: http://lkml.indiana.edu/hypermail/linux/kernel/0003.3/0248.html (Accessed: 29 August 2010).

 

Advertisements

2 Comments »

  1. 1
    Clinton Says:

    Hi there, the whole thing is going sound here and ofcourse every one
    is sharing data, that’s genuinely fine, keep up writing.

  2. I visited many web sites but the audio feature for audio songs present
    at this website is really wonderful.


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: