Course OS1 Chapter2 Prat2 2023
Course OS1 Chapter2 Prat2 2023
Course OS1 Chapter2 Prat2 2023
Course Material
Level: 2LMD
Module manager: Ms. D. Boukhlouf
Example (see figure above) Virtual Address Space and Physical Space: The process in its continuous
virtual space consists of four pages: A, B, C and D. Three blocks are located in the physical memory
and one is on the disk.
It would be too expensive to assign any process a full address space, especially because many use only
a small portion of its address space. In general, virtual memory and physical memory are structured in
allocation units (pages for virtual memory and frames for physical memory). The size of a page is
equal to that of a frame. When a process is running, only part of its address space is in memory.
The virtual addresses referenced by the current statement must be translated into physical addresses.
This address conversion is performed by hardware management circuits.
If this address corresponds to an address in physical memory, the actual address is transmitted to the
bus, Otherwise a page fault occurs.
For example, if the physical memory is 32 KB and the addressing is 16-bit, the logical address space
can reach size 216 or 64 KB.
The address space is structured into a set of units called pages or segments, which can be loaded
separately into memory.
All of its address space (virtual memory) is stored on disk. To run a process, the operating system
loads into memory only one or a few units (pages or segments) including the one that contains the
beginning of the program. When a process is running, only part of its address space is in main
memory. This part is said to be resident. Parts of this space are loaded into main memory on demand.
They can be dispersed in central memory.
It first checks whether the number of the virtual page is present in the associative memory, comparing
it simultaneously (in parallel) to all entries. If it finds it and the access mode conforms to the
protection bits, the box is taken directly from the associative memory (without going through the
Table of pages). If the page number is present in the associative memory but the access mode is non-
compliant, a protection defect occurs. If the page number is not in the associative memory, the MMU
accesses the Page Table at the entry corresponding to the page number. If the presence bit of the
found input is 1, the MMU replaces one of the entries in the associative memory with the found input.
Otherwise, it causes a page fault.
This algorithm does not take into account the use of each page. For example, at the tenth reference
page 0 is removed to be replaced by page 3 and then immediately after the removed page is reloaded.
The algorithm is rarely used because there are a lot of page faults.
Belady anomaly: this anomaly, studied by Belady, Nelson, Shedler, is specific to the FIFO strategy.
Intuition leads us to think that the more space there is in main memory, the fewer page defects. In
reality (this is the anomaly), this is sometimes false. The example below explains this paradox: in a 3-
frame memory, there are 9 page faults; In a memory with 4 frames (therefore larger), we meet for the
same treatment 10 page faults.
The problem with this algorithm is the difficulty of implementation, which requires hardware
support. You need a way to memorize the time each time a page is referenced. We can also use an
aging technique, where a register of n bits is associated with each page. The most significant bit is set
LRU algorithm;
10.5 Replacement of the least frequently used page: LFU(Least frequently used)
We keep a counter that is incremented each time the frame is referenced, and the victim will be the
frame with the lowest meter.
Example:
Reference chain: 7-0-1-2-0-3-0-4-2-3-0-3-2-1-2-0-1-7-0-1.
12. Segmentation
In a paginated system, the virtual address space of a process is one-dimensional. In general, a process
is composed of a set of logical units:
The different codes: the main program, the procedures, the library functions.
. Initialized data.
. Uninitialized data.
. Execution stacks.
The idea of the segmentation technique is to have a two-dimensional address space. Each logical unit
can be associated with an address space called a segment. The address space of a process is
composed of a set of segments. These segments are of different sizes (external fragmentation). A
segmentation address translation scheme is shown in the figure below. Segmentation makes it easy to
edit links, as well as share data segments or codes between processes.