|
3 | 3 | \sltitle{Virtual memory implementation} |
4 | 4 | \begin{itemize} |
5 | 5 | \item processes in UNIX use virtual addresses to access physical memory. |
6 | | -The virtual - physical convertion is performed by hardware with the help |
| 6 | +The virtual - physical conversion is performed by hardware with the help |
7 | 7 | of kernel. |
8 | 8 | \item in case of memory shortage unused parts of memory are stored to |
9 | | -(\emsl{swap}) space on disk. |
| 9 | +(\emsl{swap}) space on disk. |
10 | 10 | \item before SVR2 the \texttt{swapper} process (nowadays |
11 | | -\texttt{sched}) swapped out whole processes. |
| 11 | +\texttt{sched}) swapped out whole processes. |
12 | 12 | \item from SVR2 on (\emsl{demand paging}) is used with \emsl{copy-on-write}. |
13 | 13 | Pages are allocated only after first use and private pages are copied only |
14 | 14 | after modification. Freeing and swapping of individual pages is performed |
|
18 | 18 | \end{slide} |
19 | 19 |
|
20 | 20 | \begin{description} |
21 | | -\item[překlad adres:] přístup na neplatnou adresu nebo pokus o zápis |
22 | | -do paměti pouze pro čtení vyvolá signál \texttt{SIGSEGV}. |
23 | | -\item[swap:] odkládací prostor se vytváří na samostatném oddílu |
24 | | -disku, od SVR4 může být i v~souboru. |
25 | | -\item[swapper:] proces \texttt{swapper} se snaží odložit na disk nějaký |
26 | | -proces, který není zam\-čen v~paměti, a na uvolněné místo zavést dříve |
27 | | -odložený proces. |
28 | | -\item[demand paging:] při žádosti procesu o paměť se pouze upraví |
29 | | -tabulka stránek. První instrukce adresující obsah stránky vyvolá |
30 | | -výjimku. Jádro ji ošetří tím, že alokuje stránku. |
31 | | -\item[copy-on-write:] více procesů může sdílet zapisovatelnou |
32 | | -fyzickou stránku, která je ale logicky privátní pro každý proces |
33 | | -(tato situace nastane např. po vytvoření procesu voláním |
34 | | -\texttt{fork}). Dokud procesy z paměti pouze čtou, přistupují ke |
35 | | -sdíl{}ené stránce. Pokud se proces pokusí obsah stránky změnit, vyvolá |
36 | | -výjimku. Jádro zkopíruje stránku, přidělí procesu kopii, která už je |
37 | | -privátní a proces ji může dále libovolně měnit. Ostatní procesy |
38 | | -používají stále ne\-změ\-ně\-nou původní stránku. |
39 | | -\item stránky k odložení se hledají algoritmem \emph{NRU} (not recently |
40 | | -used): každá stránka má příznaky \texttt{referenced} a |
41 | | -\texttt{modified}, na začátku vynulované. Při prvním přístupu se |
42 | | -nastaví \texttt{referenced}, při změně \texttt{modified}. Oba |
43 | | -příznaky se periodicky nulují. Přednostně se uvolňují stránky, které |
44 | | -nejsou modifikované ani použité. Stránky kódu programu a mapovaných |
45 | | -souborů se neukládají do odkládacího prostoru, ale obnovují se z |
46 | | -příslušného souboru. |
| 21 | +\item[address translation:] access to invalid address or attempt to write into |
| 22 | +read-only memory will result in the \texttt{SIGSEGV} signal to be delivered. |
| 23 | +\item[swap:] swap area is created on separate disk partition, since |
| 24 | +SVR4 it can be also in a file. |
| 25 | +\item[swapper:] the \texttt{swapper} process tries to saved a process that is |
| 26 | +not into memory to disk and use the free space for process that was swapped out |
| 27 | +earlier. |
| 28 | +\item[demand paging:] when a process requests a memory only the page is |
| 29 | +modified. The first instruction addressing the page contents will result in an |
| 30 | +exception. The kernel will handle it by allocating a page. |
| 31 | +\item[copy-on-write:] multiple processes can share writable physical page that |
| 32 | +is however logically private to each process (such situation happens e.g. when a |
| 33 | +process is created by the \texttt{fork} system call). Until the processes only |
| 34 | +read from the memory, they access the shared page. First attempt to write will |
| 35 | +cause an exception. The kernel will copy the page and assign a copy of the |
| 36 | +page to the process that is already a private and the process can change it. |
| 37 | +The other process keep using the original page. |
| 38 | +\item The pages to be swapped out are searched for by the \emph{NRU} (not |
| 39 | +recently used) algorithm: each page has the \texttt{referenced} and |
| 40 | +\texttt{modified} flags, both zero initially. First access will set |
| 41 | +\texttt{referenced}, a change will set \texttt{modified}. |
| 42 | +Both flags are periodically nullified. The pages that are neither modified or |
| 43 | +used are freed first. The program code pages and pages of mapped files are not |
| 44 | +stored into swap area, they are fetched from given file. |
47 | 45 | \end{description} |
48 | 46 |
|
49 | 47 | %%%%% |
|
0 commit comments