Question: provide constructive feedback and ask some meaningful questions about this comment: This week we went over memory management in an OS . The main difference

provide constructive feedback and ask some meaningful questions about this comment: This week we went over memory management in an OS. The main difference between physical memory and logical, or similarly virtual memory, is physical memory is fixed in place and fixed in size. Physical memory is dictated by the actual memory modules installed on the machine in question. Logical memory is the memory that the OS allocates for certain programs and processes. And virtual memory often has variable size, and different locations based on process needs. Virtual memory is used when more memory is needed than is physically available. Some related concepts to this are swapping, segmentation, paging and page faults, and fragmentation.
Swapping - Swapping is when you have a process that is too large to fit in the current amount of available memory, so you can swap some processes from primary memory to secondary memory to free up space to bring in the new process. This is useful because then you can store many other processes in secondary memory which has an abundance of storage space, while keeping the current processes in primary memory for fast access.
Segmentation - Segmentation divides the program into many different small segments for different parts of the code, such as the variables, constants, data, stacks and more. This is useful because everything is specifically divided for each part of the overall program and so you can get more exact fits for each segment rather than having to find one larger contiguous space of memory for everything to live in. It is also beneficial because it can be faster to access certain parts because they are smaller and easier to look through rather than having to look through the entirety of the program to find variables for example. Segmentation can be more complex to program for though because it involves a lot more address translation to make the different segments work together for the one program. As well, it can lead to fragmentation.
Fragmentation - Fragmentation happens when free memory started to become scattered, and it becomes harder and harder to find contiguous memory to be able to store things. Segmentation can easily cause this because instead of blocking out a large contiguous space in memory for a program, it is breaking it up into many smaller segments, and thus instead of just having one hole at the end of the program with free space, you can end up with many smaller holes in between each segment that are smaller to the point that they are not usable to store anything. And then that memory space is basically lost and useless until swapping or compacting can be done to re organize the memory in a way that brings the free space together in a contiguous manner.
Paging/Page Fault - Finally there is paging and page faults. Paging divides the virtual address space of processes into multiple fixed-size blocks called pages. Conversely with the physical memory, page frames are created. Page frames are the same size as the pages and are also of fixed-size. Paging is similar to segmentation, but is more specifically used when there is not enough physical memory available, and virtual memory must be used instead. When a process gets loaded into the main memory, the os will map the pages of the process's virtual address space to the physical address space. By using this method, the virtual memory, to the program, is all contiguous and easy to manage, however, it isn't necessarily using contagious physical memory, thus allowing for usage of more virtual memory than there is physical memory, or at minimum using more contiguous virtual memory than there is physical contiguous memory.
Finally, a page fault is what happens when a process tries to reference a virtual page that is not present in physical memory (has not been mapped). And thus a trap is triggered and the operating system intervenes. This will cause a page replacement, which will remove a page from physical memory to make room for the requested page. This is a similar process to swapping as described above, where it will bring in the page from secondary memory and swap it into the location where the other page was removed. Though instead of swapping entire programs or processes, it is simply just swapping the page itself. Making more a lighter and faster process. Also, page replacement may happen less often than swapping as the majority of a program might be able to run it's main parts without page swapping, until a certain function at the end might need to be accessed and then a page swap occurs. While with conventional swapping, this could happen several times during regular usage to make space for the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!