c - 为什么32bit的内存只需要1bit的map

标签 c memory-management bitmap operating-system

我正在阅读 Tannenbaum 的《现代操作系统》Memory Management with Bitmaps一书,但发现很难理解他这句话的含义

The smaller the al- location unit, the larger the bitmap. However, even with an allocation unit as small as 4 bytes, 32 bits of memory will require only 1 bit of the map.

为什么 4 个字节(32 位)的内存在映射中只占用 1 位?

screenshot from book

最佳答案

此上下文中的位图用于指示正​​在分配哪些内存块。

Why will 4 bytes (32bit) of memory occupy only 1 bit in the map?

它们不占用 1 位。一口确定这 4 个字节是否正在使用。

The smaller the allocation unit, the larger the bitmap. However, even with an allocation unit as small as 4 bytes, 32 bits of memory will require only 1 bit of the map.

假设您有一个 1024 字节的内存池并且要使用此技术。如果允许分配 128 字节,则意味着位图只需要 8 位 (8*128 = 1024)。如果分配 64 字节,则位图需要 16 位。

我不得不说,这是指示已分配磁盘簇的正常且习惯的方式,我怀疑它是否占用了太多内存。

关于c - 为什么32bit的内存只需要1bit的map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43873488/

相关文章:

c# - 从数组创建位图对象

c++ - Windows编程对话框背景图片

c - 将文本文件读入 c 字符串

c - 跟随 malloc(0) 返回的指针

c - Valgrind 使用 asprintf 报告内存泄漏

c - 如何调整由函数创建的字符数组中的内存大小?

c - 使用 switch-case 结构来计算数字被输入的次数

linux - 内存使用率超过 100%

performance - 为什么 JIT 语言仍然比原生 C/C++ 更慢且内存效率更低?

android - android中圆的尖角(在 Canvas 上绘制)