免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5434 | 回复: 11
打印 上一主题 下一主题

虚拟内存管理 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-17 12:55 |只看该作者 |倒序浏览
这篇Jeff Berryman 1972年写的关于“虚拟内存管理”的小品文,是我见到的关于VM的最好的说明文档。翻译了前半部分(寓言故事的部分),与大家共享。
duke_gun
2005/11/17

Rules
1. Each player gets several million things.
2. Things are kept in crates that hold 4096 things each. Things in the same crate are
called crate-mates.
3. Crates are stored either in the workshop or the warehouse. The workshop is almost
always too small to hold all the crates.
4. There is only one workshop but there may be several warehouses. Everybody shares
them.
5. Each thing has its own thing number.
6. What you do with a thing is to zark it. Everybody takes turns zarking.
7. You can only zark your things, not anybody else's.
8. Things can only be zarked when they are in the workshop.
9. Only the Thing King knows whether a thing is in the workshop or in a warehouse.
10. The longer a thing goes without being zarked, the grubbier it is said to become.
11. The way you get things is to ask the Thing King. He only gives out things in multiples
of eight. This is to keep the royal overhead down.
12. The way you zark a thing is to give its thing number. If you give the number of a thing
that happens to be in a workshop it gets zarked right away. If it is in a warehouse, the
Thing King packs the crate containing your thing back into the workshop. If there is no
room in the workshop, he first finds the grubbiest crate in the workshop, whether it be
yours or somebody else's, and packs it off with all its crate-mates to a warehouse. In
its place he puts the crate containing your thing. Your thing then gets zarked and you
never know that it wasn't in the workshop all along.
13. Each player 's stock of things have the same numbers as everybody else's. The Thing
King always knows who owns what thing and whose turn it is, so you can't ever
accidentally zark somebody else's thing even if it has the same thing number as one of
yours.
Notes
1. Traditionally, the Thing King sits at a large, segmented table and is attended to by
pages (the so-called "table pages") whose job it is to help the king remember where
all the things are and who they belong to.
2. One consequence of Rule 13 is that everybody's thing numbers will be similar from
game to game, regardless of the number of players.
3. The Thing King has a few things of his own, some of which move back and forth
between workshop and warehouse just like anybody else's, but some of which are just
too heavy to move out of the workshop.
4. With the given set of rules, oft-zarked things tend to get kept mostly in the workshop
while little-zarked things stay mostly in a warehouse. This is efficient stock control.
Long Live the Thing King!


规则
1.每位选手都有数以百万计的Things.
2.所有的Things都保存在箱子里,每个箱子可以保存4096个Things.保存在同一个箱子里的Things互为“箱友”。
3.箱子只能放置在车间或者仓库中。车间太小了,总是放不下所有的箱子。
4.车间只有一个,仓库却有多个。所有选手共用车间和仓库。
5.每个Thing都有一个Thing number.
6.选手的工作就是对Things进行锻压,所有人轮流进行锻压操作。
7. 你只能锻压自己的Things,而绝不能锻压别人的。
8.只能在车间里对Things进行锻压。
9.只有Thing King才知道一个Thing究竟是在车间里还是在仓库里。
10.一个Thing得不到锻压的时间越长,就越可能被认为是废品(被标记为”dirty”)。
11.选手要通过Thing King才能开展工作。Thing King每次给出的Thing的数目是8的整数倍,这是为了降低维护性开销。
12.你要锻压一个Thing,只需给出它的Thing number.如果你所说的Thing恰好就在车间里,它立即就会被锻压。如果它在仓库里,Thing King负责把装它的那个箱子搬运到车间来。如果车间里没有了空位,Thing King会找出车间里最脏的(等待被锻压时间最长的)箱子——不管它是你的还是谁的,搭载这个箱子过来的“箱友”都会被赶出车间,回到仓库。Thing King为你的箱子找到了空位,接着就去锻压你说的那个Thing了。想一想,当你提到某个Thing时,你知道它在车间还是仓库里吗——你总是不知道;当你看到你说的Thing被锻压了,你了解Thing King所作的上述工作吗——你总是不知道。这些对你都是透明的(transparent)——存在但你却看不到。
13.所有选手的Things采用同样的编号方式。Thing King总是清楚哪个Thing是哪个选手的以及现在该谁来操作锻压了。所以,即使存在你的Thing和别人的Thing使用同样编号(number)的现象,你也不会偶尔锻压了别人的Thing.

说明
1.传统上,Thing King会坐在一个巨大的、分成一段一段的桌子旁边,附近还有一些页(被称作“桌页”)。桌页用来帮助Thing King记住所有的Things在什么地方、属于谁。
2.规则13带来的一个现象就是在各场游戏中,无论选手人数多还是少,每个选手的Thing number都很相似。
3.Thing King也有自己的Things,其中一些Things会和选手们的Things一样,在车间和仓库间搬来搬去;也有一些实在太重了,只能长期留在车间里。
4.根据给定的规则,经常被锻压的Things会被尽可能地留在车间里;那些很少会被锻压的Things会被尽可能地留在仓库里。这有助于提高存储控制的效率。

论坛徽章:
0
2 [报告]
发表于 2005-11-17 16:01 |只看该作者

第二部分

Rules
1. Each player gets several million "bytes."
2. Bytes are kept in "pages" that hold 4096 bytes each. Bytes on the same page have
"locality of reference".
3. Pages are stored either in memory or on a disk. The memory is almost always too
small to hold all the pages.
4. There is only one memory but there may be several disks. Everybody shares them.
5. Each byte has its own "virtual address."
6. What you do with a byte is to "reference" it. Everybody takes turns referencing.
7. You can only reference your bytes, not anybody else's.
8. Bytes can only be referenced when they are in memory.
9. Only the "VM manager" knows whether a byte is in memory or on a disk.
10. The longer a byte goes without being referenced, the "older" it is said to become.
11. The way you get bytes is to ask the VM manager. It only gives out bytes in multiples
of powers of two. This is to keep overhead down.
12. The way you reference a byte is to give its virtual address. If you give the address of a
byte that happens to be in the memory it gets referenced right away. If it is on disk,
the VM manager brings the page containing your byte back into the memory. If there
is no room in the memory, it first finds the oldest page in the memory, whether it be
yours or somebody else's, and packs it off with the rest of the page to a disk. In its
place it puts the page containing your byte. Your byte then gets referenced and you
never know that it wasn't in the memory all along.
13. Each player 's stock of bytes have the same virtual addresses as everybody else's. The
VM manager always knows who owns what byte and whose turn it is, so you can't
ever accidentally reference somebody else's byte even if it has the same virtual
address as one of yours.
Notes
1. Traditionally, the VM manager uses a large, segmented table and "page tables" to
remember where all the bytes are and who they belong to.
2. One consequence of Rule 13 is that everybody's virtual addresses will be similar from
run to run, regardless of the number of processes.
3. The VM manager has a few bytes of his own, some of which move back and forth
between memory and disk just like anybody else's, but some of which are just too
heavily used to move out of the memory.
4. With the given set of rules, oft-referenced bytes tend to get kept mostly in the
memory while little-used bytes stay mostly in a disk. This is efficient memory
utilization.
Long Live the VM Manager!

论坛徽章:
0
3 [报告]
发表于 2005-11-18 14:56 |只看该作者
没人看么?自己顶下。

论坛徽章:
0
4 [报告]
发表于 2005-11-19 14:19 |只看该作者
好多人看、没人说话。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2005-11-19 14:24 |只看该作者
ULK2 的内存管理那里说的挺好的了.再结合操作系统的相关知识.我感觉比较贴近实际.

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2005-11-19 14:25 |只看该作者
好帖!

论坛徽章:
0
7 [报告]
发表于 2005-11-19 14:33 |只看该作者
原帖由 flw 于 2005-11-19 14:25 发表
好帖!


既然版主说是好贴了,那我就不能不看了。

(嗯,我也最讨厌个人崇拜)

^_^

论坛徽章:
0
8 [报告]
发表于 2005-11-21 18:20 |只看该作者
原帖由 flw 于 2005-11-19 14:25 发表
好帖!
呵呵,终于有识货的了。

论坛徽章:
0
9 [报告]
发表于 2006-08-17 17:37 |只看该作者
wonderful

论坛徽章:
0
10 [报告]
发表于 2006-08-17 19:23 |只看该作者
lz应该说一下thing , workshop, warehouse, crate, thing king, 等等代表什么
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP