-
Notifications
You must be signed in to change notification settings - Fork 0
Memory Allocator
zliang7 edited this page Jan 26, 2016
·
3 revisions
- Buddy allocator
- Alternative: Bitmap allocator (page size = 64KB, map size = 2KB/GB)
- API:
- void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
- fd == -1, support MAP_PRIVATE | MAP_ANONYMOUS only
- Always R/W, ignore prot
- int munmap(void *addr, size_t length);
- Dummy:
- int madvise(void *addr, size_t length, int advice);
- int mlock(const void *addr, size_t len);
- int mlockall(int flags);
- int mprotect(void *addr, size_t len, int prot);
- int msync(void *addr, size_t length, int flags);
- int munlock(const void *addr, size_t len);
- int munlockall(void);
- Slab allocator
- API
- void* malloc(size_t size);
- void free(void *ptr);
- void *memalign(size_t alignment, size_t size);
- int posix_memalign(void **memptr, size_t alignment, size_t size);
- Wrapper:
- void* calloc(size_t count, size_t size);
- void* realloc(void *ptr, size_t size);