Chinaunix首页 | 论坛 | 博客
  • 博客访问: 824484
  • 博文数量: 116
  • 博客积分: 1472
  • 博客等级: 上尉
  • 技术积分: 1725
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-06 11:45
文章分类

全部博文(116)

文章存档

2015年(1)

2014年(42)

2013年(5)

2012年(19)

2011年(49)

我的朋友

分类: 嵌入式

2014-02-06 10:35:51

 

------------------

The older "ram disk" mechanism created a synthetic block device out of  an area of RAM and used it as backing store for a filesystem. This block

device was of fixed size, so the filesystem mounted on it was of fixed size.

"ram disk"是一种实现文件系统的块(后备存储器)、是过时的机制(2.6不用了),就是在RAM上面开辟的综合后备存储器(synthetic block device),并使用它作为一个文件系统的后备存储。由于这个块设备的大小是固定的,所以挂载在它上面的文件系统的大小(不是ramfs)也是固定的。

Using a ram disk also required unnecessarily copying memory from the fake block device into the page cache (and copying changes back out), as well as creating and destroying dentries. Plus it needed a filesystem driver (such as ext2) to format and interpret this data.

与创建和删除目录一样,ramdisk的使用也需要执行一项不必要的多余的操作:从这个假的后备存储器page cache之间拷贝内存数据,生成和销毁dentry;另外,ram disk需要文件系统的驱动程序来格式化和解释上面的数据,所以ram disk的机制不再使用

Compared to ramfs, this wastes memory (and memory bus bandwidth), creates unnecessary work for the CPU, and pollutes the CPU caches. (There are tricks to avoid this copying by playing with the page tables, but they're unpleasantly complicated and turn out to be about as expensive as the copying anyway.)

与ramfs相比较,ramdisk的上述特点会浪费内存(和内存总线带宽),给CPU增加了不必要的工作,污染了CPU的cache(尽管有避免污染的方法,但是非常耗费资源)。

More to the point, all the work ramfs is doing has to happen _anyway_,since all file access goes through the page and dentry caches. The RAM disk is simply unnecessary; ramfs is internally much simpler.Another reason ramdisks are semi-obsolete is that the introduction of loopback devices offered a more flexible and convenient way to create synthetic block devices, now from files instead of from chunks of memory.

ramfs机制非常自然,因为文件访问可以通过page cache and dentry cache。内存磁盘是简单且多余的,ramfs在内部更为简单。ram disk被弃用的另外一个原因是环回设备(loopback)引入,使得ramdisks成为了半过时的技术。环回设备提供了一种更加灵活、方便的从文件而不是从内存块中创建综合后备存储器的方法。


See losetup (8) for details.

重要认识点:

  1. ramdisk是块设备,ramfs是文件系统,看字面意思就知道
  2. 由于ramdisk是块设备,所以可以作为后备存储器,因此也常常作为文件系统的后备存储
  3. ramdisk所占据的内存空间是大小固定的(一经设定,就不可改变大小)
阅读(2045) | 评论(0) | 转发(0) |
0

上一篇:ramfs

下一篇:ramfs and tmpfs

给主人留下些什么吧!~~