Linux Buddy算法&系统分析

几个BUDDY算法示意图:

参考内核实现的用户态BUDDY实现代码:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "br_list.h"

#define MAX_ORDER       11
#define DBG(fmt, ...)   do { \
    printf("%s line %d, "fmt, __func__, __LINE__, ##__VA_ARGS__); \
} while (0)

struct page {
	struct br_list_head list;
	int page_idx;
	int order;
};

struct br_list_head slab_list[MAX_ORDER];
struct page page_array[1024];

猜你喜欢

转载自blog.csdn.net/tugouxp/article/details/130696451