MCPcopy Create free account
hub / github.com/YatSenOS/YatSenOS-Tutorial-Volume-1 / BitMap

Class BitMap

lab7/src/3/include/bitmap.h:6–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "os_type.h"
5
6class BitMap
7{
8public:
9 // 被管理的资源个数,bitmap的总位数
10 int length;
11 // bitmap的起始地址
12 char *bitmap;
13public:
14 // 初始化
15 BitMap();
16 // 设置BitMap,bitmap=起始地址,length=总位数(即被管理的资源个数)
17 void initialize(char *bitmap, const int length);
18 // 获取第index个资源的状态,true=allocated,false=free
19 bool get(const int index) const;
20 // 设置第index个资源的状态,true=allocated,false=free
21 void set(const int index, const bool status);
22 // 分配count个连续的资源,若没有则返回-1,否则返回分配的第1个资源单元序号
23 int allocate(const int count);
24 // 释放第index个资源开始的count个资源
25 void release(const int index, const int count);
26 // 返回Bitmap存储区域
27 char *getBitmap();
28 // 返回Bitmap的大小
29 int size() const;
30private:
31 // 禁止Bitmap之间的赋值
32 BitMap(const BitMap &) {}
33 void operator=(const BitMap&) {}
34};
35
36#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected