《现代操作系统》阅读笔记

中文名:现代操作系统
英文名:Modern Operating Systems
7.4~7.8 回家这几天把这本书看掉了,重拾了当初学操作系统的感觉,这的确是一本好书。
同我们当时那本汤子瀛的教材相比,这本书就是The C Language 之于 谭浩强的书。
今天来到学校就把心得总结了一下,作者挺幽默的,并且思维很开阔,大家风范。
由于没有找到中文版本的非影印版,于是就用英文版(3rd)的做总结了,标注的页码却是2rd。
呃,作者你可能不熟悉(荷)Andrew.S.Tanenbaum 但是,Minix你一定听过,那么我想你知道了。

封面上的趣图:

 

 

不多说了,以下为总结:
1. P9 个体的重复发展
原定义:
在达尔文(Charles Darwin)的著作《物种起源》之后,德国动物学家海克尔(Ernst Haeckel)指出了“个体重复发展”现象。
他的意思是,一个胚胎(个体)重复五中(个体)的演化。换句话说,在卵子受精之后,一个人类的卵子在成为婴儿之前,
经过了是鱼、是猪以及是其他物种的阶段。现在生物学家认为这是一种粗略的简化说法,不过这个说法的内部包含有真理的成分。
书中引用:
在计算机产业中有着类似的情形。每一个物种(大型机,小型计算机,个人计算机,嵌入式计算机,智能卡等)似乎经历着
它的前辈经历过的发展历程。第一代大型机完全使用汇编语言编程,甚至复杂的程序,如编译器和操作系统,也是用汇编语言写的。
到了小型计算机出现时,FORTRAN、COBOL和其他高级语言在大型机中已经普及,但是小型计算机却使用汇编语言编程。(因为空间不足)
微型计算机和掌上型计算机也是从汇编代码开始但是迅速的移植到高级语言上。(主要原因是开发工作在较大的机器上)
2. P24 /44 重用
After Charles Darwin's book On the Origin of the Species was published, the 
German zoologist Ernst Haeckel stated that "ontogeny recapitulates phylogeny." 
By this he meant that the development of an embryo (ontogeny) repeats (i.e., 
recapitulates) the evolution of the species (phylogeny). In other words, after fer-
tilization, a human egg goes through stages of being a fish, a pig, and so on before 
turning into a human baby. Modern biologists regard this as a gross simplification, 
but it still has a kernel of truth in it. 
Something vaguely analogous has happened in the computer industry. Each 
new species (mainframe, minicomputer, personal computer, handheld, embedded 
computer, smart card, etc.) seems to go through the development that its ancestors 
did, both in hardware and in software. We often forget that much of what hap-
pens in the computer business and a lot of other fields is technology driven. The 
reason the ancient Romans lacked cars is not that they liked walking so much. It 
is because they did not know how to build cars. Personal computers exist not be-
cause millions of people have a centuries-old pent-up desire to own a computer, 
but because it is now possible to manufacture them cheaply. We often forget how 
much technology affects our view of systems and it is worth reflecting on this 
point from time to time. 
In particular, it frequently happens that a change in technology renders some 
idea obsolete and it quickly vanishes. However, another change in technology 
could revive it again. This is especially true when the change has to do with the 
relative performance of different parts of the system. For instance, when CPUs 
became much faster than memories, caches became important to speed up the 
"slow" memory. If new memory technology someday makes memories much 
faster than CPUs, caches will vanish. And if a new CPU technology makes them 
faster than memories again, caches will reappear. In biology, extinction is for-
ever, but in computer science, it is sometimes only for a few years. 
大段话的意思就是,计算机中的思想不会过时,按需求变更。
3. P79 /137 均衡性
用户对做一件事情需要多长时间总有一种固定的(不过通常不正确)看法。当认为一个请求很复杂需要较多时间时,
用户会接受这个看法,但当认为一个请求很简单,但也需要较多时间时,用户就会很急躁。
4. P203 /354 Modern Kindergarten
The solution was the introduction of TrueType fonts, which are not bitmaps 
but outlines of the characters. Each TrueType character is defined by a sequence 
of points around its perimeter. All the points are relative to the (0, 0) origin. 
Using this system, it is easy to scale the characters up or down. All that has to be 
done is to multiply each coordinate by the same scale factor. In this way, a True-
Type character can be scaled up or down to any point size, even fractional point 
sizes. Once at the proper size, the points can be connected using the well-known 
follow-the-dots algorithm taught in kindergarten (note that modern kindergartens 
use splines for smoother results). After the outline has been completed, the char-
acter can be filled in.
作者在这里开了有意思的玩笑,“现代幼儿园”。
5. P267 /466 Joke Of JPEG
JPEG may seem complicated, but that is because it is complicated. Still, 
since it often produces a 20:1 compression or better, it is widely used. Decoding a 
JPEG image requires running the algorithm backward. JPEG is roughly sym-
metric: it takes about as long to decode an image as to encode it. 
JEPG看起来十分复杂,这是因为它确实复杂。作者大大又在这里冷幽默了一把。
6. P280 /487 Zipf定律
For many kinds of popularity contests, such as movies being rented, books 
being checked out of a library, Web pages being referenced, even English words 
being used in a novel or the population of the largest cities, a reasonable approxi-
mation of the relative popularity follows a surprisingly predictable pattern. This 
pattern was discovered by a Harvard professor of linguistics, George Zipf (1902-
1950) and is now called Zipf's law. What it states is that if the movies, books, 
Web pages, or words are ranked on their popularity, the probability that the next 
customer will choose the item ranked k-th in the list is C/k, where C is a nor-
malization constant. 
Thus the fraction of hits for the top three movies are C/1, C/2, and C/3, re-
spectively, where C is computed such that the sum of all the terms is 1. In other 
words, if there are N movies, then 
C/1 + C/2 + C/3 + C/4 + ... + C/N = 1 
From this equation, C can be calculated. The values of C for populations with 10, 
100, 1000, and 10,000 items are 0.341, 0.193, 0.134, and 0.102, respectively. For 
example, for 1000 movies, the probabilities for the top five movies are 0.134, 
0.067, 0.045, 0.034, and 0.027, respectively. 
这个算法可以计算出排行中每个。
7. P350 /607 登录欺骗
The only real way to prevent this is to have the login sequence start with a key 
combination that user programs cannot catch. Windows uses CTRL-ALT-DEL 
for this purpose. If a user sits down at a computer and starts out by first typing 
CTRL-ALT-DEL, the current user is logged out and the system login program is 
started. There is no way to bypass this mechanism.
设置那个按键组合的目的就是为了一般程序不能将之屏蔽。
8. P349 /606 Trojan Horses
Most common programs are in /bin or /usr/bin, so putting a Trojan horse in 
/usr/bin/X////s does not work for a common program because the real one will be 
found first. However, suppose the cracker inserts la into /un-/bin/XI] . If a user 
mistypes la instead of Is (the directory listing program), now the Trojan horse will 
run, do its dirty work, and then issue the correct message that la does not exist. 
By inserting Trojan horses into complicated directories that hardly anyone ever 
looks at and giving them names that could represent common typing errors, there 
is a fair chance that someone will invoke one of them sooner or later. And that 
someone might be the superuser (even superusers make typing errors), in which 
case the Trojan horse now has the opportunity to replace /bin/is with a version 
containing a Trojan horse, so it will be invoked all the time now. 
Our malicious but legal user, Mal, could also lay a trap for the superuser as 
follows. He puts a version of Is containing a Trojan horse in his own directory 
and then does something suspicious that is sure to attract the superuser's attention, 
such as starting up 100 compute-bound processes at once. Chances are the 
superuser will check that out by typing 
cd /home/mal 
ls —l
to see what Mal has in his home directory. Since some shells first try the local 
directory before working through $PATH, the superuser may have just invoked 
Mal's Trojan horse with superuser power and bingo. The Trojan horse could then 
make /home/inal/bin/sh SETUID root. All it takes is two system calls: chown to 
change the owner of /hoine/inal/bin/sh to root and chmod, to set its SETUID bit. 
Now Mal can become superuser at will by just running that shell. 
这几个办法有点巧妙。
9. P363 /630 病毒变异
变异引擎一般通过对病毒加入冗余代码实现。
10. P380 /661 Covert Channel 隐藏信道
The collaborator can try to detect the bit stream by carefully monitoring its 
response time. In general, it will get better response when the server is sending a 
0 than when the server is sending a 1. This communication channel is known as a 
covert channel
However, sometimes it can still leak out using covert channels, such as modulating CPU usage. 
it->指代信息(泄露)
这让我想起了以前看到的一种用thread sleep time 对数组进行排序的娱乐算法。
11. P381 /663 Covered Writing 隐写术
How does this covert channel work? The original color image is 1024 x 768 
pixels. Each pixel consists of three 8-bit numbers, one each for the red, green, and 
blue intensity of that pixel. The pixel's color is formed by the linear superposition 
of the three colors. The encoding method uses the low-order bit of each RGB 
color value as a covert channel. Thus each pixel has room for 3 bits of secret 
information, one in the red value, one in the green value, and one in the blue 
value. With an image of this size, up to 1024 x 768 x 3 bits (294,912 bytes) of 
secret information can be stored in it. 
用每个RGB颜色值低位作为隐藏信道。
12. P315 /547 竞标算法
把任务看成商品,由各个处理机进行"竞价"
13. P393 /684 过滤程序(filter)和管线命令(pipeline)
A program that reads its input from standard input, does some processing on it, 
and writes its output to standard output is called a filter. 
A collection of commands connected by pipe symbols, called a 
pipeline, may contain arbitrarily many commands. A four-component pipeline is 
shown by the following example: 
grep ter *.t | sort | head —20 | tail —5 >foo 
Here all the lines containing the string "ter" in all the files ending in .t are written 
to standard output, where they are sorted. The first 20 of these are selected out by 
head, which passes then to tail, which writes the last five (i.e., lines 16 to 20 in 
the sorted list) to foo. This is an example of how Linux provides basic building 
blocks (numerous filters), each of which does one job, along with a mechanism 
for them to be put together in almost limitless ways. 
和以前编程中用到的.net remoting中的PIC管道就是这个东东,记下linux下写法,备个忘。
14. P395/686 A few of the common Linux utility programs required by POSIX. 
一些常用的命令。管他是不是posix集中的,熟悉一下。
cat 
Concatenate multiple files to standard output 
chmod 
Change file protection mode 
cp 
Copy one or more files 
cut 
Cut columns of text from a file 
grep 
Search a file for some pattern 
head 
Extract the first lines of a file 
Is 
List directory 
make 
Compile files to build a binary 
mkdir 
Make a directory 
od 
Octal dump a file 
paste 
Paste columns of text into a file 
pr 
Format a file for printing 
ps 
List running processes 
rm 
Remove one or more files 
rmdir 
Remove a directory 
sort 
Sort a file of lines alphabetically 
tail 
Extract the last lines of a file 
tr 
Translate between character sets 
15. 一点小Tip
window开发过程有个编译号,白天各组的代码提交,重新生成一个编译版本,晚上交付高压测试。第二天继续编写。
后话: 以前学面向对象的时候,觉得一切事物都是对象;现在看了操作系统,觉得一切都是状态机。比如磁盘,呵呵。
MINIX获取:http://www.minix3.org/
posted @ 2011-07-09 17:30  淡萣  阅读(2522)  评论(4编辑  收藏  举报