Last Sync: 2022-08-31 18:30:05

This commit is contained in:
tactonbishop 2022-08-31 18:30:05 +01:00
parent 90eb3f90c7
commit 0c7383e472
2 changed files with 40 additions and 1 deletions

View file

@ -52,4 +52,23 @@ $ uptime
- A load average close to 0 is usually a good sign because it means that your processor isn't being challenged and you are conserving power. Anything equal to or above 1 means that a single process is using the CPU nearly all the time. You can identify that process with `htop` and it will obviously be near to the top. (This is often caused by Chrome and Electron-based software.)
## Memory
## Memory status
We know that processes primarily interact with virtual memory in the form of pages which are then translated to physical blocks by the kernel via the [MMU](/Operating_Systems/Virtual_memory_and_the_MMU.md). There are several tools which provide windows onto this process.
### System page size
We can view the overall system page size which is a representation of the amount of virtual memory available:
```bash
$ getconf PAGE_SIZE
4096
```
This will typically be the same for all Linux systems.
### Page faults
There are two kinds of error that can occur with relation to paged memory:
-

View file

@ -4,3 +4,23 @@ categories:
- Hardware
tags: [memory]
---
# Virtual memory and the Memory Management Unit
## What is virtual memory?
Virtual memory is implemented at the level of the operating system and is an abstraction on top of 'real', physical memory (i.e the charges stored within the actual DRAM component.).
When virtual memory is used, the CPU handles physical memory allocation and presents this to the kernel as an idealised representation. This means that the kernel and, by extension, programs and processes do not need to think about accessing the real memory blocks. This reduces complexity because often memory will be allocated in places that are non-contiguous with similar running processes or be located in the cache or swap memory on the disk.
It would take considerable processing workd for the kernel to be tracing these disparate memory sources at every instance. By working on an idealised (contiguous, unlimited) memory set the kernel can focus on task management and CPU sequencing as its primary task.
The memory is idealised in that all locations are represented virtually as being contiguous (even when this is not physically the case). Secondly, quantities of available memory can be presented as much larger than is actually the case and which often exceed the physical memory limits of the device. This is achieved through paging, handled by the MMU.
## The Memory Management Unit (MMU)
Without an MMU, when the CPU accesses RAM, the actual RAM locations never change. The memory address is always the same physical location within the RAM. The MMU is a chip that sits within the CPU and RAM recalculating the actual memory address from the virtual memory location requested by the kernel.
## Pages
We use the term **pages** to denote blocks of virtual memory and to distinguish them from **addresses** as physical blocks. The MMU possesses a **page table** which is registry logging which pages correspond to which physical blocks.