Rev 38 | Rev 45 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 38 | Rev 39 | ||
---|---|---|---|
Line 22... | Line 22... | ||
22 | 22 | ||
23 | <listitem> |
23 | <listitem> |
24 | Allowing, in general, to load and execute two programs that are linked on the same address without complicated relocations. |
24 | Allowing, in general, to load and execute two programs that are linked on the same address without complicated relocations. |
25 | </listitem> |
25 | </listitem> |
26 | </itemizedlist></para> |
26 | </itemizedlist></para> |
27 | - | ||
28 | 27 | ||
29 | <para><!-- |
28 | <para><!-- |
30 | 29 | ||
31 | TLB shootdown ASID/ASID:PAGE/ALL. |
30 | TLB shootdown ASID/ASID:PAGE/ALL. |
32 | TLB shootdown requests can come in asynchroniously |
31 | TLB shootdown requests can come in asynchroniously |
33 | so there is a cache of TLB shootdown requests. Upon cache overflow TLB shootdown ALL is executed |
32 | so there is a cache of TLB shootdown requests. Upon cache overflow TLB shootdown ALL is executed |
34 | 33 | ||
Line 41... | Line 40... | ||
41 | 40 | ||
42 | --></para> |
41 | --></para> |
43 | </section> |
42 | </section> |
44 | 43 | ||
45 | <section> |
44 | <section> |
46 | - | ||
47 | - | ||
48 | <title>Paging</title> |
45 | <title>Paging</title> |
49 | 46 | ||
50 | <para>Virtual memory is usually using paged memory model, where virtual |
47 | <para>Virtual memory is usually using paged memory model, where virtual |
51 | memory address space is divided into the <emphasis>pages</emphasis> |
48 | memory address space is divided into the <emphasis>pages</emphasis> |
52 | (usually having size 4096 bytes) and physical memory is divided into the |
49 | (usually having size 4096 bytes) and physical memory is divided into the |
53 | frames (same sized as a page, of course). Each page may be mapped to some |
50 | frames (same sized as a page, of course). Each page may be mapped to |
54 | frame and then, upon memory access to the virtual address, CPU performs |
51 | some frame and then, upon memory access to the virtual address, CPU |
55 | <emphasis>address translation</emphasis> during the instruction |
52 | performs <emphasis>address translation</emphasis> during the instruction |
56 | execution. Non-existing mapping generates page fault exception, calling |
53 | execution. Non-existing mapping generates page fault exception, calling |
57 | kernel exception handler, thus allowing kernel to manipulate rules of |
54 | kernel exception handler, thus allowing kernel to manipulate rules of |
58 | memory access. Information for pages mapping is stored by kernel in the |
55 | memory access. Information for pages mapping is stored by kernel in the |
59 | <link linkend="page_tables">page tables</link></para> |
56 | <link linkend="page_tables">page tables</link></para> |
60 | 57 | ||
61 | - | ||
62 | - | ||
63 | <para>The majority of the architectures use multi-level page tables, |
58 | <para>The majority of the architectures use multi-level page tables, |
64 | which means need to access physical memory several times before getting |
59 | which means need to access physical memory several times before getting |
65 | physical address. This fact would make serios performance overhead in |
60 | physical address. This fact would make serios performance overhead in |
66 | virtual memory management. To avoid this <link linkend="tlb">Traslation |
61 | virtual memory management. To avoid this <link linkend="tlb">Traslation |
67 | Lookaside Buffer (TLB)</link> is used.</para> |
62 | Lookaside Buffer (TLB)</link> is used.</para> |
68 | 63 | ||
69 | - | ||
70 | - | ||
71 | <para>At the moment HelenOS does not support swapping.</para> |
64 | <para>At the moment HelenOS does not support swapping.</para> |
72 | 65 | ||
- | 66 | <para>- pouzivame vypadky stranky k alokaci ramcu on-demand v ramci |
|
73 | <para>- pouzivame vypadky stranky k alokaci ramcu on-demand v ramci as_area - na architekturach, ktere to podporuji, podporujeme non-exec stranky </para> |
67 | as_area - na architekturach, ktere to podporuji, podporujeme non-exec |
- | 68 | stranky</para> |
|
74 | </section> |
69 | </section> |
75 | 70 | ||
76 | <section> |
71 | <section> |
77 | <title>Address spaces</title> |
72 | <title>Address spaces</title> |
78 | 73 | ||
79 | <section> |
74 | <section> |
80 | <title>Address spaces and areas</title> |
75 | <title>Address spaces and areas</title> |
81 | 76 | ||
82 | <para> |
- | |
83 | - | ||
84 | - adresovy prostor se sklada z tzv. address space areas |
77 | <para>- adresovy prostor se sklada z tzv. address space areas |
85 | usporadanych v B+stromu; tyto areas popisuji vyuzivane casti |
78 | usporadanych v B+stromu; tyto areas popisuji vyuzivane casti |
86 | adresoveho prostoru patrici do user address space. Kazda cast je dana |
79 | adresoveho prostoru patrici do user address space. Kazda cast je dana |
87 | svoji bazovou adresou, velikosti a flagy (rwx/dd). |
80 | svoji bazovou adresou, velikosti a flagy (rwx/dd).</para> |
88 | - | ||
89 | </para> |
- | |
90 | 81 | ||
91 | <para>- uzivatelske thready maji moznost manipulovat se svym adresovym |
82 | <para>- uzivatelske thready maji moznost manipulovat se svym adresovym |
92 | prostorem (vytvaret/resizovat/sdilet) as_areas pomoci syscallu</para> |
83 | prostorem (vytvaret/resizovat/sdilet) as_areas pomoci syscallu</para> |
93 | </section> |
84 | </section> |
94 | 85 | ||
Line 114... | Line 105... | ||
114 | <para>- vztah task ~ adresovy prostor: teoreticky existuje moznost, ze |
105 | <para>- vztah task ~ adresovy prostor: teoreticky existuje moznost, ze |
115 | je adresovy prostor sdilen vice tasky, avsak tuto moznost nepouzivame |
106 | je adresovy prostor sdilen vice tasky, avsak tuto moznost nepouzivame |
116 | a neni ani nijak osetrena. Tim padem plati, ze kazdy task ma vlastni |
107 | a neni ani nijak osetrena. Tim padem plati, ze kazdy task ma vlastni |
117 | adresovy prostor</para> |
108 | adresovy prostor</para> |
118 | </section> |
109 | </section> |
119 | - | ||
120 | - | ||
121 | - | ||
122 | </section> |
110 | </section> |
123 | 111 | ||
124 | <section> |
112 | <section> |
125 | <title>Virtual address translation</title> |
113 | <title>Virtual address translation</title> |
126 | 114 | ||
Line 219... | Line 207... | ||
219 | </section> |
207 | </section> |
220 | 208 | ||
221 | <section id="frame_allocator"> |
209 | <section id="frame_allocator"> |
222 | <title>Frame allocator</title> |
210 | <title>Frame allocator</title> |
223 | 211 | ||
- | 212 | <para><mediaobject id="frame_alloc"> |
|
- | 213 | <imageobject role="html"> |
|
- | 214 | <imagedata fileref="images/frame_alloc.png" format="PNG" /> |
|
- | 215 | </imageobject> |
|
- | 216 | ||
- | 217 | <imageobject role="fop"> |
|
- | 218 | <imagedata fileref="images.vector/frame_alloc.svg" format="SVG" /> |
|
- | 219 | </imageobject> |
|
- | 220 | </mediaobject></para> |
|
- | 221 | ||
224 | <formalpara> |
222 | <formalpara> |
225 | <title>Overview</title> |
223 | <title>Overview</title> |
226 | 224 | ||
227 | <para>Frame allocator provides physical memory allocation for the |
225 | <para>Frame allocator provides physical memory allocation for the |
228 | kernel. Because of zonal organization of physical memory, frame |
226 | kernel. Because of zonal organization of physical memory, frame |
Line 260... | Line 258... | ||
260 | <title>Buddy allocator</title> |
258 | <title>Buddy allocator</title> |
261 | 259 | ||
262 | <section> |
260 | <section> |
263 | <title>Overview</title> |
261 | <title>Overview</title> |
264 | 262 | ||
- | 263 | <para><mediaobject id="buddy_alloc"> |
|
- | 264 | <imageobject role="html"> |
|
- | 265 | <imagedata fileref="images/buddy_alloc.png" format="PNG" /> |
|
- | 266 | </imageobject> |
|
- | 267 | ||
- | 268 | <imageobject role="fop"> |
|
- | 269 | <imagedata fileref="images.vector/buddy_alloc.svg" format="SVG" /> |
|
- | 270 | </imageobject> |
|
- | 271 | </mediaobject></para> |
|
- | 272 | ||
265 | <para>In buddy allocator, memory is broken down into power-of-two |
273 | <para>In buddy allocator, memory is broken down into power-of-two |
266 | sized naturally aligned blocks. These blocks are organized in an array |
274 | sized naturally aligned blocks. These blocks are organized in an array |
267 | of lists in which list with index i contains all unallocated blocks of |
275 | of lists in which list with index i contains all unallocated blocks of |
268 | the size <mathphrase>2<superscript>i</superscript></mathphrase>. The |
276 | the size <mathphrase>2<superscript>i</superscript></mathphrase>. The |
269 | index i is called the order of block. Should there be two adjacent |
277 | index i is called the order of block. Should there be two adjacent |
Line 299... | Line 307... | ||
299 | lack of this knowledge, the buddy allocator exports an interface that |
307 | lack of this knowledge, the buddy allocator exports an interface that |
300 | each of its clients is required to implement. When supplied an |
308 | each of its clients is required to implement. When supplied an |
301 | implementation of this interface, the buddy allocator can use |
309 | implementation of this interface, the buddy allocator can use |
302 | specialized external functions to find buddy for a block, split and |
310 | specialized external functions to find buddy for a block, split and |
303 | coalesce blocks, manipulate block order and mark blocks busy or |
311 | coalesce blocks, manipulate block order and mark blocks busy or |
304 | available. For precize documentation of this interface, refer to <link |
312 | available. For precize documentation of this interface, refer to |
305 | linkend="???">HelenOS Generic Kernel Reference Manual</link>.</para> |
313 | <emphasis>"HelenOS Generic Kernel Reference Manual"</emphasis>.</para> |
306 | 314 | ||
307 | <formalpara> |
315 | <formalpara> |
308 | <title>Data organization</title> |
316 | <title>Data organization</title> |
309 | 317 | ||
310 | <para>Each entity allocable by the buddy allocator is required to |
318 | <para>Each entity allocable by the buddy allocator is required to |
Line 392... | Line 400... | ||
392 | </section> |
400 | </section> |
393 | 401 | ||
394 | <section> |
402 | <section> |
395 | <title>Implementation</title> |
403 | <title>Implementation</title> |
396 | 404 | ||
- | 405 | <para><mediaobject id="slab_alloc"> |
|
- | 406 | <imageobject role="html"> |
|
- | 407 | <imagedata fileref="images/slab_alloc.png" format="PNG" /> |
|
- | 408 | </imageobject> |
|
- | 409 | ||
- | 410 | <imageobject role="fop"> |
|
- | 411 | <imagedata fileref="images.vector/slab_alloc.svg" format="SVG" /> |
|
- | 412 | </imageobject> |
|
- | 413 | </mediaobject></para> |
|
- | 414 | ||
397 | <para>The SLAB allocator is closely modelled after <ulink |
415 | <para>The SLAB allocator is closely modelled after <ulink |
398 | url="http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/"> |
416 | url="http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/"> |
399 | OpenSolaris SLAB allocator by Jeff Bonwick and Jonathan Adams </ulink> |
417 | OpenSolaris SLAB allocator by Jeff Bonwick and Jonathan Adams </ulink> |
400 | with the following exceptions: <itemizedlist> |
418 | with the following exceptions: <itemizedlist> |
401 | <listitem> |
419 | <listitem> |