Add diagram to doc
This commit is contained in:
parent
ed55f1cc23
commit
350b5c41c3
@ -27,12 +27,13 @@ A given entry N in the PD point to the PD (this is possible because PDE very loo
|
||||
Then, accessing N * 4Mo + I * 4Ko is accessing the PT of the Ieme entry in the PD (as MMU take the PD pointed by the PDE number N like a PT).
|
||||
More particularly, accessing N * 4Mo + N * 4ko is accessing the PD.
|
||||
|
||||
PD is at Vaddr N * 4Mo and take 4ko. Each PT are allocated dynamically.
|
||||
Just make sure that N have not been used by identity mapping
|
||||
PD is at Vaddr N * 4Mo and take 4ko. Each PT is allocated dynamically.
|
||||
Just make sure that N have not been used by identity mapping.
|
||||
|
||||
## Virtual memory allocators
|
||||
|
||||
We will setup 2 different virtual memory allocator:
|
||||
We will setup 2 different virtual memory allocators:
|
||||
|
||||
* `allocArea` for large memory area of several PAGE_SIZE size
|
||||
* `alloc` for object of any size
|
||||
|
||||
@ -44,10 +45,11 @@ An area is represented by `struct memArea` and basically consist of a virtual me
|
||||
This is a simple allocator keeping 2 linked list of used/free area.
|
||||
|
||||
Allocating a new area (thanks to `areaAlloc()`) consist of:
|
||||
1. finding an area big enough in the free list.
|
||||
2. split it if the found area is too large.
|
||||
3. put the found area in the user area list.
|
||||
4. optionally map the area to physical page
|
||||
|
||||
1. Finding an area big enough in the free list.
|
||||
2. Split it if the found area is too large.
|
||||
3. Put the found area in the user area list.
|
||||
4. Optionally map the area to physical pages.
|
||||
|
||||
Freeing an area (thank to `areaFree()`) consist of trying to find adjacent free area and merge them with this one or just adding the area to the free one.
|
||||
|
||||
@ -57,9 +59,38 @@ Freeing an area (thank to `areaFree()`) consist of trying to find adjacent free
|
||||
For large object allocation ( > PAGE_SIZE), this a basically a call to `areaAlloc()`.
|
||||
For smaller object, this is a more complex allocator based on the concept of slab.
|
||||
|
||||
The allocator is configured at startup to maintain slab for allocating object of a given size.
|
||||
So a slab is a linked list of `struct slabEntry` having each of the entries pointing to one or several memory area that is divided in chunk of the slab configured size.
|
||||
It's a linked list so it is each to add a new `struct slabEntry` when one is full.
|
||||
Inside a `struct slabEntry` the `freeEl` attribute point to the next free chunk (of the slab configured size) in the allocated page(s). At this address is also a pointer to the next free area in this area.
|
||||
The allocator is configured at startup to maintain a collection of slabs, each of them configured for allocating object of a given size.
|
||||
So a slab is described by `struct slabDesc` and contains a linked list of `struct slabEntry`.
|
||||
Each of the `struct slabEntry` entry point to a memory area that is divided in chunk of the slab configured size.
|
||||
It's a linked list so it is easy to add a new `struct slabEntry` when one is full.
|
||||
Inside a `struct slabEntry` the `freeEl` attribute point to the next free chunk (of the slab configured size) in the allocated page(s). At this address is also a pointer to the next free area in this area.
|
||||
|
||||
.-----------------------------.
|
||||
| struct slabEntry { |
|
||||
| vaddr_t page; |-------------------->.---------------------.
|
||||
| void *freeEl; |-------------. |.------------------. |
|
||||
| size_t size; | | || allocated chunk | |
|
||||
| bool_t full; | | |.-------------------.|
|
||||
| struct slabEntry *next; || -------->| addr of next free |----.
|
||||
| struct slabEntry *prev; || |.------------------.'| |
|
||||
| }; || || allocated chunk | | |
|
||||
'-----------------------------'| |.------------------. | |
|
||||
.------------------------------' || NULL |<----'
|
||||
'-->.-----------------------------. |.------------------. |
|
||||
| struct slabEntry { | || allocated chunk | |
|
||||
| vaddr_t page; | |'------------------' |
|
||||
| void *freeEl; | '---------------------'
|
||||
| size_t size; |
|
||||
| bool_t full; |
|
||||
| struct slabEntry *next; ||
|
||||
| struct slabEntry *prev; ||
|
||||
| }; ||
|
||||
'-----------------------------'|
|
||||
.----------------------------------'
|
||||
'-->.-----.
|
||||
| ... |
|
||||
'-----'
|
||||
|
||||
So there is one slab for object of 4B, one for 126B ...
|
||||
The linked-list containing all the slab (`struct slabDesc`) is called the slub.
|
||||
|
||||
|
BIN
docs/slab_diag.asiio
Normal file
BIN
docs/slab_diag.asiio
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user