Memory management - 1 Flashcards
- What is the Hard-Disk for?*
- Synonym: secondary storage*
It is used to store a large amount of data, which are not currently in use.
- What is the RAM(random access memory)?*
- Synonyms: physical memory, main memory, primary storage, or just, memory.*
Main memory holds the programs and data loaded into the computer from even slower storage, like disk or network, in order for it to be prepared for CPU usage.(relatively close to the CPU)
What is a cache for?
Cache is a temporary storage which resides within the processor chip(nearer to CPU than RAM), thus smaller and faster.
What is a register for?
Nearest to the CPU, smallest memory units - used for computations of the CPU and help follow the instructions pipeline
What is a virtual memory, and what is it for?
- It is a simulated memory that is written to a file on the hard-drive.
that file is also called: page-file or swap file
- It is used by the OS to simulate physical RAM by using hard disk space. It allows us to run more applications on the system.
What is a volatile memory?
volatile means that it can be changed rapidly. That is, it can easily lose the data. For instance, RAM is considered volatile because once power is cut-off, data is lost.
who’s responsible for transferring memory from the secondary storage(disk) to the main storage(RAM)?
The memory manager
n proceses, each spending a fraction p of their time waiting for I/O(for instance , p = 0.7 means the process spends 70% of its time waiting for I/O). what is the probabilty of all processes waiting for I/O simultaneously?
p^n
Assume each process takes 200k(of the RAM) and so does the OS.
Assume there is 1MB in the RAM, and that p=0.
- What would be the CPU utilization for the max number of processes we can run simultaneously?
- What if we add another 1MB?
Including the OS, we can add 4 more processes. (200*5 =1000)
- The probability of all 4 processes waiting simultaneously for I/O, which is the worst case scenario of CPU utilization, is 0.8^4 = 0.4096. that also means that in the worst case, the CPU utilization stand on about 60%(because 40% is taken by I/O)
- If we add another 1MB, we have space for additional 5 processes. that means worst case scenario 0.8^9≈0.13% of the time the CPU has no work to do. CPU utilization is thus around 0.87%.
What is an External fragmentation?
What is an Internal fragmentation?
External: When a process cannot allocate required memory space because memory is non-contiguous.
It occurs due to dynamic partitioning.
This can be cured using: compaction, segmentation and paging
Internal: When the RAM is divided into fixed-sized partitions, each for a loaded process, and we meet the case in which we don’t have space for process to be loaded even though the other processes in RAM don’t use all the fixed-sized memory they’ve been given.
What is compaction?
Eliminating unnecessary redundancy in order to reduce the amount of data stored without loss of information. In addition, it shuffles memory contents to place all free memory together in one large block.
It is only possible if reallocation is dynamic.
This process helps to cure fragmentation.
What is segmentation?
- Dividing the memory into segments:*
- The code.*
- Uninitialized - bss*
- The global variables*
- The heap*
- the stack*
- the standard C library.*
- This memory management scheme helps to estimate the amount of memory needed for any part mentioned above. This is another tool to cure fragmentation.*
- In addition, the segments don’t interfere one with the other due to the help of the segmentation table, which using the base address and the limit of each segment, knows to tell if an address, which is given by: {segment number, offset} can be addressed or it exceeds the limit of the segment. If the latter, it may result with a segmentation fault.*
What is paging?
Paging allows the physical address space of a process to be noncontiguous. (fixing external fragmentation).
Paging** is implemented by breaking the **main memory** into fix-sized blocks that are called **frames.
- The virtual memory of a process is broken into the same fixed-sized blocks called pages.*
- When a program is to be executed, the pages of the program are loaded from disk into any available frames in main memory.*
- The CPU generates the virtual address space of the process. Each virtual address consists of two parts: {page number;page offset}.*
- Each process has its own page table, which contains the base address of each page that was loaded in main memory. Combined with the page offset it generates the address of the required data in memory.*
What is daemon?
A daemon is a process(program) that runs in the background on a multi-tasking OS.
That means, it is detached from a terminal and runs continuously in a non-interactive mode.
A way to create a deamon is by forking a child process and then exiting the parent.
How Memory Allocation is tracked?
Using a map of bit - bitmap.
Using a linked list