This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
In this term paper we are going to study a very important characterstic of operating system i.e Memory Management , how the memory is managed between various operations , processes
We began with brief description about memory management system . .In this term paper we will be much focused n how this system works rather than comparing its architecture & structure
Memory management is the heart of operating systems; it is crucial for both programming and system administration. So we should be much bothered by its workin and how actually it works and how it is
Memory management in Microsoft Windows operating systems has evolved into a rich and sophisticated architecture, capable of scaling from the tiny embedded platforms where Windows executes from ROM all the way up to the multi-terabyte NUMA configurations, taking full advantage of all capabilities of existing and future hardware designs.
Linux implements the virtual memory data structure just like UNIX. Virtual memory area structures are maintained in linked lists by it. These data structures represent continuous memory areas which are containing the same protection parameters.
MEMORY MANAGEMENT SYSTEM:-
Memory management system is important part of each operating system. The main function of this system is to manage the memory system of random access memory and the other storing devices which are available on the system. Main tasks that come under the memory management are allocation and deallocation of memory to the various processes running on the system. The memory management system should be optimized as its function affects the speed and the performance of the operating system.
Memory management system provides the following features:
Large Address Space
The memory management system shows the user that large memory space is available instead of the actual memory it has. Virtual memory is many times greater than the physical memory of the system.
Every process of the system is provided the virtual address space. These address spaces completely differ from each other so the processes running on one application program not affect the other. The hardware also protects the virtual memory area from writing. Thus code and data is protected from getting overwritten by rogue applications.
Memory mapping is used to map image and data files into a processes address space. In memory mapping function, the contents of a file are linked directly into the virtual address space of the process.
Fair Physical Memory Allocation
The memory management subsystem allows each running process in the system a fair share of the physical memory of the system
Shared Virtual Memory
Virtual memory is the main and an important part of the memory management system. The memory requirements were growing that's why the virtual memory was introduced. So programs were developed that made the illusion that system has large memory to be allocated to the processes. The kernels provide the facility to use the secondary storage devices to fulfill the extra requirements of the memory.
Some mapping functions are there for the virtual memory function to work. These functions are responsible for the address translation that converts the virtual addresses to the physical addresses..
Virtual memory function generally use the paging or segmentation as per the need of the operating system.
In paging both the address space the virtual and real is divided into fixed size pages. The pages are manipulated and is placed at different place in hard disk and the physical memory. The memory management unit does the address translation by using the page. The address page table
specifies the mapped physical pages and the virtual memory pages. The memory management unit changes the virtual memory address to the physical memory address consisting page frame number and the offset in that page. It also provides the functionality to apply protection on the page. Virtual memory takes the large address space in comparison to physical memory. With each virtual page a bit is associated with the page table to check if the page is present anyhow or not. If the page is not there a page fault exception is generated. It is handled by the software which place the pages required back to the physical memory from the hard disk and error is generated if it is invalid
Both the operating systems have the modern operating systems and have a lot of common features in between them. Some of the similarities in both of the memory management system are-
Hardware Abstraction Layer :
Both the operating systems have the hardware abstraction layer that is not system dependent. Thus the kernels are enabled to be coded independently.
Copy on write:-
If the pages are shared same copy of the page is used between the processes. But if an individual process makes any change in the page that is made private to that process only, thus increases the efficiency.
Windows on 32 bit x86 systems accesses upto 4GB of physical memory. This is because that the processor's address bus which is 32 lines or 32 bits can only access address range from 0x00000000 to 0xFFFFFFFF that is of 4GB. Windows provides 4Gb logical space for each process.. The lower 2GB is for the user mode process and upper 2GB is reserved for Kernel mode code of the Windows. This operating system uses paging feature for managing the memory
Paging allows the software to use a logical memory address than the physical memory address.
Windows provides an independent, 2 GB user address space for each and every application (process) in the system. To the application only 2 GB of memory is appeared to be available than the total memory available. When an application requests more memory than the available memory, Windows NT satisfies the request by paging noncritical pages of memory-from this and/or other processes-to a page file and freeing those physical pages of memory. Thus a global heap exists for no long in the Windows NT. Every process gets the private 32-bit address space from which all of the memory for the process is allocated-including code, resources, data, DLLs (dynamic-link libraries), and dynamic memory. The system is still limited by whatever hardware resources are available, but the management of available resources is performed independently of the applications in the system.
Linux implements it memory data i.e virtual data same as UNIX. virtual memory area structures are maintained in linked lists by it. These data structures represent continuous memory areas which are containing the same protection parameters . This list is searched when a page is to be referred for a location i.e known or we can say for exact location. This also records the range of address that is getting mapping onto & protection mode also whether it has been in memory as not page-able and also specifies the direction whether in upward or downward direction . This also specify if that is a public or a private location If in case the entries increases than a 32, then tree is formed rather than link list .This approach is best in all most of the situations
Process Address Space :-
Both the operating system distribute the process virtual address space in the same way. Higher part is used by the kernel and lower by the lower part. The kernel part all process point to the same kernel code. So now as process switching is concerned, we need to switch the lower page enteries , whereas as upper part can be remained untouched. In linux there is space of in ratio 3:1 that is 3 gb for processes to use and 1 gb for kernel to excute its operations whereas in case of windows this is an equal ratio of 2:2 that is 2gb , 2gb for both processes and kernel
The window system is very complicated one. Windows for fetching the pages use a clusted demand paging approach ,and for the page replacement Window uses a clock algorithm approach
In clustered demanding approach there is demanding of pages only when they are required , also when windows even demand for pages the window bring cluster of 1-8 pages at once according to present state of the system or acc to the required scenario
The various page faults received by kernel -
A protection violation has occurred.
A shared page has been written.
The stack needs to grow. in.
These errors are mostly not recoverable. The third only one attempts to read write only that page somewhere else and make the new one read/write. In this way the copy-on-write works.
The clock algorithm used by Windows is local. When a page fault occurs, and faulting process's working set is below a minimum threshold, then the page is simply added to the working set.
On the other hand, if the working set is higher than one another threshold, then it reduces the size of working set. Hence the algorithm can be called global.
But the system does do some global optimizations too. For example, it increases the working set of processes that are causing a large number of page faults, and decreasing the working set for those who do not require enough memory. Instead of just working when there is a page fault, just like Unix,
Windows has a daemon thread working too, but called in this case as Balance Set Manager. This is invoked every 1 second, and it checks whether there is enough free memory. If there is not, then it invokes the working set manager. The working set manager maintains to keep the free memory above threshold. It checks the working sets of process from old and big to the young and small. And depending on how many page faults they have generated, it increases or decreases them. If a page's reference bit is clear, then counter associated with the page is incremented. If the reference bit is set, the counter is set to zero. After the scan, pages with the highest counter are removed from the working set. Thus, the global aspect of this clock algorithm is given by this working set manager.
Windows divides the list of pages into four lists:
1. Modified Page List
2. Stand-bye Page list
3. Free Page list
4. Zeroed Page List
The Linux Virtual memory just focus on the fact that it is to be simple and has less overheads . Therfore it has many problems when used under heavy load processes . It uses a demand paging . that too even with not pre demanding feature .Before the linux version 2.2 , this O.S used NRU Algorithm for page replacement but due toits a lot of problems and shortcomings , the made a new approach that was Lru (leasr recently used ) an approximated aaproach. The effectness of anging process to LRU is done by increasing the age of a page by a constant when the page is found to be referenced during a scan. Least Recently Used (Lru) is approximated fairly in this
This Virtual Pages Are divided into 4 lists in Linux system
Inactive dirty List
Inactive clean List
For Linux 2.4, the dynamicity was introduced for inactive list Now in this system automatically decide how many number of pages t keep in this memory in the as per given situation. And also
Decide the unactive pages to keep in the memory or not in any given situation
Another optimization present in the Linux Kernel, is that they now recognize continuous I/O, i.e. they now decrease the priority of the page "behind" and so that page becomes a candidate for eviction sooner. The page daemon in Linux is kswapd which awakens once a second, and frees memory if enough is not available
Both the systems are originated in different backgrounds -
Windows was created taken in account to keep Commercial Settings and
Whereas Linux taken in account for Hackers .
Both are equally important as per the environment and requirements of the user
Both have many similar functions and operations just with a few differences
Windows is developed with motivation and it has gone through more effort in its design and development.
In case of Linux, the decision is taken favouring simplicity .over its performance
Therefore the Windows is developed into sophisticated, complex code whereas Unix is simple and elegant but still modern. The result of which is that Windows has more features but is difficult to maintain and improve from the developers, while Unix has less features but is easier to maintain and develop. Windows is likely to give better performance while occasionally crashing