ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
kingsley-alloc.h
Go to the documentation of this file.
1
#ifndef KINGSLEY_ALLOC_H
2
#define KINGSLEY_ALLOC_H
3
4
#include <stdint.h>
5
#include <list>
6
7
class
KingsleyAlloc
8
{
9
public
:
10
KingsleyAlloc
(
void
);
11
~KingsleyAlloc
();
12
13
KingsleyAlloc
*
Clone
(
void
);
14
void
SwitchTo
(
void
);
15
uint8_t *
Malloc
(uint32_t size);
16
void
Free
(uint8_t *buffer, uint32_t size);
17
uint8_t *
Realloc
(uint8_t *oldBuffer, uint32_t oldSize, uint32_t newSize);
18
// Call me only from my context
19
void
Dispose
();
20
21
private
:
22
// The following structure is unique for all clone of this.
23
struct
Mmap
24
{
25
uint32_t
refcount
;
// TODO think about what is happen when refcount come back to one ?
26
// Perhaps free copy ?
27
uint32_t
size
;
28
uint8_t *
buffer
;
29
uint8_t *
current
;
// Where to save current context , is used when another context is coming up
30
// Zero if there is no clone yet(refcount == 1)
31
};
32
33
// But this one is differente between the clones.
34
struct
MmapChunk
35
{
36
struct
Mmap
*
mmap
;
37
uint8_t *
copy
;
// My own copy of mmap->buffer used when there is at less one clone else ZERO.
38
uint32_t
brk
;
// Amount of memory used.
39
};
40
struct
Available
41
{
42
struct
Available
*
next
;
43
};
44
void
MmapAlloc
(uint32_t size);
45
void
MmapFree
(uint8_t *buffer, uint32_t size);
46
uint8_t *
Brk
(uint32_t needed);
47
uint8_t
SizeToBucket
(uint32_t size);
48
uint32_t
BucketToSize
(uint8_t bucket);
49
50
std::list<struct KingsleyAlloc::MmapChunk>
m_chunks
;
51
struct
Available
*
m_buckets
[32];
52
uint32_t
m_defaultMmapSize
;
53
};
54
55
56
#endif
/* KINGSLEY_ALLOC_H */
model
kingsley-alloc.h
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2