Memory is an important resource for operating systems, and therefore, must be managed carefully. It is the job of the operating system to coordinate how the memory resource is managed. Memory management strategies are used in computer systems to simultaneously keep many processes in the memory in order to allow multiprogramming. It is the job of the operating system to keep track of which parts of memory are being used and which parts aren’t in order to efficiently allocate memory to processes whenever they need it and deallocate when they are done. It should also manage the swapping between the main memory and the disk when the former is too small to hold the entire process.
Two commonly used operating systems are Windows and Unix. Beginners and everyday computer users usually use Windows, while more advanced users use Unix. Both of these operating systems have their pros and cons.
Windows uses a tree data structure in managing virtual memory wherein every node in the tree is called a Virtual Address Descriptor (VAD). The VAD marks each node of the tree as either free, reserved, or committed virtual memory. A process can be committed to memory or be reserved for future use. Before any free address can be used, first, it has to be allocated as either reserved or committed. Meanwhile, Unix uses a linked list data structure that begins to search whenever a page is found and then records the address range, protection mode, and the growth direction. If the entry number become greater than 32, Unix converts the linked list into a tree data structure, depending on the current situation.
Both the memory management systems of Windows and Unix distribute the process virtual address in the same way. Windows uses paging on 32-bit systems will have access of up to 4GB of both logical address space and physical memory. For Windows kernel-mode, the upper part of the address space is given 2 GB of memory space while the lower part is given the same amount of memory space in user-mode. Unix can access 4 GB of physical memory but the upper part is only allowed to use 1 GB of memory space in kernel-mode, while the lower part is given 1 GB in user mode.
In order to extend the available space in the physical memory (RAM) of a computer, using the virtual memory would be an efficient method. Both Windows and Unix make use of this method in order to make the memory available for a process that is much bigger compared to the physical memory of the computer. Each process gets a private 2 GB of virtual address space in 32-bit systems while in 64-bit systems, each processes in both Windows and UNIX get 8 TB of address space.
Memory relocation is an important part in any memory management system since it is where the operating system performs memory allocation. Windows makes use of cluster demand paging, wherein the pages are only allocated into the memory once it is necessary. Instead of bringing in chunks of pages one by one, Windows will simultaneously bring an entire page in the memory. Pages that are in the main memory will then be altered accordingly. This memory relocation method is called “First In, First Out” (FIFO) method and it is used by Windows.
Unix handles memory relocation by using demand paging wherein any unnecessary pages will not be swapped into the memory. Using this method will allow the operating system to avoid or not read pages that are currently not being used. This lessens the amount of physical memory and the time needed in page swapping. This algorithm used in Unix is called the “Least Recently Used” (LRU) Algorithm.
Memory management also provides a protection scheme. In Windows, a protection bit is associated with each memory frame. In the page table, a valid-invalid bit is added to each entry and if a bit is valid, it means that the page is present in the logical address space of a process. However, if a bit is invalid, it means that a page isn’t present in the logical address space, which leads to the generation of a page fault.
Memory management protection in Unix makes use of linked list data structures, which is searched whenever a page is needed. It records address ranges, modes of protection, and the up or down direction in which it grows. Unix makes use of data structures, depending on the situation.
In the process of sharing, the memory management of both Windows and UNIX use virtual memory. With Windows, a set of services are provided such as files that are memory-mapped, copy-on-write memory, large memory support, and background support for the cache manager. On the other hand, Unix makes use of dynamic libraries which is another example of executing code that is shared by multiple processes. The shared memory Inter-Process Communication (IPC) is the mechanism used as shared memory in which two or more processes exchange data using memory that is commonly shared.
It is clear that Windows and Unix both have their own advantages and disadvantages in its application for memory management in operating systems. Both of them have complex systems for memory management that answer to the needs of users when choosing an OS. Overtime, memory management systems are continuing to improve and get even more complex. We can only imagine how efficient these systems will be in the future.