-
1.1
A Closer Look at
the Processor and Primary
Storage
仔细看看处理器和主存储器
We
have learned that all
computers have
similar capabilities
and perform
essentially the same functions,
although some might be faster than others. We
have
also
learned
that
a
computer
system
has
input,
output,
storage,
and
processing
components;
that
the
processor
is
the
“intelligence”
of
a
computer
system; and that a single computer
system may have several processors. We have
discussed
how
data
are
represented
inside
a
computer
system
in
electronic
states
called bits. We are
now ready to expose the inner workings of the
nucleus of
the computer system
—
the processor.
我们已经知道,所有的计算机都具有相似的能力
,并且在本质上执行相同的功能,尽管
一些可能会比另一些快一点。我们也知
道,一个计算机系统具有输入,
输出,存储和处理部
件;
处理器是一个计算机系统智能核心,
并且一个计算机系统可以有许多个
处理器。
我们已
经讨论过如何在计算机系统内部,用被称作“位
”的电子状态来表现数据,现在我们要弄明
白计算机系统的核心,即处理器,的内在的工
作方式。
The
internal operation of a computer is
interesting,
but there really is no
mystery
to
it.
The
mystery
is
in
the
minds
of
those
who
listen
to
hearsay
and
believe
science-fiction writer. The computer is
a nonthinking electronic device that has
to be plugged into an electrical power
source, just like a toaster or a lamp.
计算机的内部操作很有意思,
但确实没有什么神秘可言。所谓的
神秘只是存在于那些听信
传闻和相信科幻小说作家的人的意识中。
计算机就是一种没有思想的需要接通电源的电子设
备而已,与烤面包机和台灯差不多。
Literally
hundreds of different types of computers are
marketed by scores of
manufacturers
[1]
. The complexity of each type may
vary considerably, but in the
end each
processor, sometimes called the central processing
unit or CPU, has only
two
fundamental
sections:
the
control
unit
and
the
arithmetic
and
logic
unit.
Primary
storage
also
plays
an
integral
part
in
the
internal
operation
of
a
processor.
These
three
—
primary
storage, the control unit, and the arithmetic and
logic unit
—
work
together. Let’s look at their functions and the
relationships between them.
不加夸张地讲,
市场上有几百种不同类型的计算机在销售
.
每种电脑在复杂性上可能有很
大区别,但归
根结底
,
每种处理器,有时称为中央处理器即
< br>cpu
,只有两个基本部分
:
控
制单
元和计算逻辑单元
.
主内存在处理
器内部操作中也是一个不可缺少的部分
.
这三个部件
--
主
内存,控制单元和计算逻辑单元
--
一起工作
.
然我们看
看它们
(
各自的
)
功能和它们之间的联
系。
Unlike
magnetic
secondary
storage
devices,
such
as
tape
and
disk,
primary
storage
has
no
moving
parts.
With
no
mechanical
movement,
data
can
be
accessed
from
primary
storage
at electronic speeds, or close to the
speed of light. Most of today’s
computers use DRAM (Dynamic Random-
Access Memory) technology for primary storage.
A
state-of-the-art
DRAM
chip
about
one
eighth
the
size
of
a
postage
stamp can
store
about 256,000,000
bits, or over 25,600,000 characters of data!
主存与其他的辅助存储器(如:磁带、硬盘)不一样的是,<
/p>
主存不含有运转部件。由于
没有机械运转的需要,
主存种数据访问可以达到电子的速度,
或接近于光速。
当今计算机的
主存大多数使用
DRAM
(动态随机存取存储器)技术。目前最新的工艺水平是:一块只有大
约
< br>1/8
张邮票大小的
DRAM
芯
片却可以存储大约
256,000,000
位,约
25,6000,000
个字符的
数据。
Primary
storage,
or
main
memory,
provides
the
processor
with
temporary
storage
for
programs
and
data.
All
programs
and
data
must
be
transferred
to
primary
storage
from
an input device (such
as a VDT) or from secondary storage (such as a
disk) before
programs can be executed
or data
can be processed. Primary
storage space is always
at a premium;
therefore, after a program has been executed, the
storage space it
occupied is
reallocated to another program awaiting execution.
主存储器
,也就是说内存,用于为处
理器暂时存放程序和数据。所有的程序和数据在被操
作之前必须从输入设备(如
VDT
)或者辅助存储器转存到主存储器中。主存储器存储容量通
常是相当有限的,
因此,
在一个程序执行结束
,
它所占用的存储空间必须被重新分配给其它
正在等待执行操作
的程序。
Figure 1-1
illustrates how all input/output (I/O)
is “read to” or “written
from” primary storage. In the figure,
an inquiry (input) is made on a VDT. The
inquiry,
in
the
form
of
a
message,
is
routed
to
primary
storage
over
a
channel
(such
as
a
coaxial
cable).
The
message
is
interpreted,
and
the
processor
initiates
action
to
retrieve
the
appropriate
program
and
data
from
secondary
storage
[3].The
program
and
data
are
“loaded”
,
or
moves,
to
primary
storage
from
secondary
storage.
This
is
a
nondestructive
read
process.
That
is,
the
program
and
data
that
are
read
reside
in
both
primary
storage
(temporarily)
and
secondary
storage
(permanently).
The
data
are
manipulated according to program instructions, and
a report is written from
primary
storage to a printer.
图
1-1
描述了输入
/
输出设备与主存储器间的读和写过程
。在图中,
p>
VDT
发出一个输入请
求,请求是以消息模
式通过通道(如同轴电缆)发送到主存储器。这个查询被解释,处理器
发起操作从辅助存
储器中调用合适的程序和数据。
程序和数据从辅助存储器传送到主存储器
中,这是一个非破坏性的读取过程,也就是说,程序和数据同时存在于主存(临时保存)和
辅助存储器(永久保存)中。根据程序指令的指示,处理器对数据进行操作,并从主存传送
一份报告到打印机。
A
program
instruction or a piece of
data
is stored in a specific
primary storage
location called an
address. Addresses permit program instructions and
data to be
located,
accessed,
and
processed.
The
content
of
each
address
is
constantly
changing
as different programs are executed and
new data are processed.
程序指
令和数据是存储在主存
中一个特殊的位置,称为地址空间。通过地址空间可以实现
计算机对程序指令和数据的定位、
访问和处理。
地址空间的内容是经常变化的,
这是由于计
算机一直在执行不
同的程序和数据。
Another
name
for
primary
storage
is
random-access
memory,
or
RAM.
A
special
type
of
primary
storage,
called
read-only
memory
(ROM),
cannot
be
altered
by
the
programmer.
The
contents
of
ROM
are
“hard
-
wired”
(designed
into
the
logic
of
the
memory chip) by the
manufacturer and can be “read only”. When you turn
on a
microcomputer system, a program in
ROM automatically readies the computer system
for use. Then the ROM program produces
the initial display screen prompt.
主存储器也称为随机存取存储器
,
或
RAM
。
还有一种特殊的主存储器,
称为只读存储器
(
ROM
)
,
这种存储器不能被程序更改存放的内容。
< br>ROM
的内容是被生产商通过硬件电路写入的,并且
不能
被重写。当你启动计算机,
ROM
中的一个程序会自动就绪等待
计算机系统的调用,然后
在显示器中显示开机提示。
A
variation
of
ROM
is
programmable
read-only
memory
(PROM).
PROM
is
ROM
into
which
you,
the user, can load
“read
-
only” programs and
data. Once a program is loaded
to
PROM,
it
is
seldom,
if
ever,
changed
[4].
However,
if
you
need
to
be
able
to
revise
the contents of PROM,
there
is EPROM, erasable PROM. Before
a write
operation,
all
the storage
cells must be erased to the same initial state.
可编程只读存储器(
PROM
)是另一种
ROM
,它可以载入只读的程序和
数据,一旦载入,将
不再改变。然而,若果你需要去修正
PRO
M
的内容,可以使用可擦可编程只读存储器。
EPROM
在进行一次写操作之前,所有的存储单元必须被还原为同一初始状态
。
A
more
attractive
form
of
read-
mostly
memory
is
electrically
erasable
programmable
read-only
memory
(EEPROM).
It
can
be
written
into
at
any
time
without
erasing prior contents; only the byte
or bytes addressed are updated.
一种更吸引人的可改写只读存储器是电可擦除可编程只读存储器
(EEPROM)
。
它可以在
任何时候
写入,而且不会擦除以前的内容;只会更新被寻址的字节。
The
EEPROM
combines
the
advantage
of
nonvolatility
with
the
flexibility
of
being
updatable in place [6], using ordinary
bus control, address, and data lines.
电可擦可编程存储器把非易失性优点和可更新
、
需要更新的地方的灵活性结合起来,
修改
时使用普通的
总线控制线、地址线和数据线。
Another form of semiconductor memory
is flash memory (so named because of
the
speed). Flash memory is
intermediate between EPROM and EEPROM in both cost
and
functionality.
Like
EEPROM,
flash
memory
uses
an
electrical
erasing
technology.
An
entire
flash
memory
can
be
erased
in
one
or
a
few
seconds,
which
is
much
faster
than
EPROM. In addition, it is possible to
erase just blocks of memory rather than an
entire chip. However, flash memory does
not provide byte-level erasure [7]. Like
EPROM,
flash
memory
uses
only
one
transistor
per
bit,
and
so
achieves
the
high
density
of
EPROM.
另一种半导体记忆体是闪存
< br>(意味着速度快)
。
闪存在性价比上处于
EPROM
和
EEPROM
之
间,
它使用电擦写技术。
整个闪存的内容可以在一到几秒内被清
除,
这是远快于
EPROM
的。
另外,
它还可以对部分记忆块而不是整个存储器进行清除。
然而,
闪存并不提供字节级的擦除。
像
EPROM
,闪存只使用一个晶体管每比特,因此可以实现高密度的
EPROM
。
Cache Memory
Program
and
data
ar
e
loaded
to
RAM
from
secondary
storage
because
the
time
required
to
access
a
program
instruction
or
piece
of
data
from
RAM
is
significantly
less
than
from
secondary
storage.
Thousands
of
instructions
or
pieces
of
data
can
be
accessed
from
RAM
in
the
time
it
would
take
to
access
a
single
piece
of
data
from
disk
storage
[8]. RAM is essentially a high-speed
holding area for data and programs. In fact,
nothing
really
happens
in
a
computer
system
until
the
program
instructions
and
data
are
moved
to
the
processor.
This
transfer
of
instructions
and
data
to
the
processor
can be time-
consuming, even at microsecond speeds. To
facilitate an even faster
transfer
of
instructions
and
data
to
the
processor,
most
computers
are
designed
with
cache
memory.
Cache
memory
is
employed
by
computer
designers
to
increase
the
computer
system throughput
(the rate at which work is performed).
程序和数据从辅助存储
器装载到
RAM
中是因为对
RAM
中的程序指令和数据
的访问时间要明
显的少于从辅助存储器访问。
数以千条的指令和
数据能被访问而只需花费从硬盘访问一次数
据的时间。
RAM<
/p>
是数据和程序的重要的高速存放区,事实上,计算机系统不会进行任何操作
直到程序指令被传入处理器进行执行,
这种指令和数据的传输是需要花费时间的
,
即使传输
速度已经是以纳秒来计算了。
为了能更快速的传输指令和数据,
大多数计算机设计使用高速
缓存。计算机设计者使用高速缓存来提高计算机系统的总处理能力(工作效率)
。
Like RAM, cache is a
high-
speed holding area for program instructions and
data.
However,
cache
memory
uses
SRAM
(Static
RAM)
technology
that
is
about
10
times
faster
than
RAM and about 100 times more expensive. With only
a fraction of the capacity
of RAM,
cache memory holds only those instructions and
data that are likely to be
needed
next
by
the
processor.
Two
types
of
cache
memory
appear
widely
in
computers.
The
first
is
referred
to
as
internal
cache
and
is
built
into
the
CPU
chip.
The
second,
external cache, is
located on chips placed close to the CPU chip. A
computer can
have several different
levels of cache memory. Level 1 cache is virtually
always
built into the chip. Level 2
cache used to be external cache but is now
typically
also built into the CPU like
level 1 cache.
和
RAM
一样
,高速缓存也是程序指令和数据的高速存储区。然而
,高速缓存使用静态
RAM
技术,这种技术比
< br>RAM
在速度上要高出
10
倍,
价格上高出
100
倍。
cache
p>
只保存内存中那
一小部分最有可能被处理器执行的指令和数据。
p>
两种类型的
cache
广泛应用于计算机,
第一
种被植入
cpu
< br>中的叫做内部高速存储,
第二种是外部高速存储,
它位于
那些靠近
cpu
的芯片
中。
一台计算机可以拥有几个不同级别的高速缓存。
一级缓存实际上总是植入芯
片中,
二级
缓存过去常常作为外部高速缓存,但是现在也像一级
缓存植入
cpu
内部。
3.2
C++
和面向对象的程序设计
一些面向对象的程序设计概念在语言间渗透。例如微软
Quick P
ascal
是允许使用对象的
第一批语言中的一个。
C++
有什么使得它是一种适合于开发面向对象程序的语言?如同先前
p>
所提到的,答案是类(
class
)数据类
型。给该语言建立对象之能力的是建立在
C
结构类型
之上的
C++
类(
cla
ss
)类型。还有,
C++
把另外几个
特性引入面向对象的程序设计,这些特
性并不包含在简单地利用对象的其他一些语言中。
C++
的优点包括强类型、
运算符重载
和较
少地强调预处理。
的确你能使用其他一些产品和采用其他一
些语言来进行面向对象的程序设
计,
但是采用
< br>C++
的众多好处是显著的。
这是为面向对象的程序设计
而设计的语言,
并非
(现
有语言的)式
样翻新。
面向对象的程序设计是一种程序设计技术,使得你能
把一些概念看作各种各样的对象。
通过使用对象,
你能表示要被
执行的任务、
它们之间的相互作用和必须观察的某些给定的条
件
。一种数据结构经常形成某个对象的基础;因此,在
C
或
C++
中,结构类型能形成某种
基本对象。<
/p>
与对象的通信,如前提到的,
能通过使用消息来完成。
消息的使用类似于在面向
过程的程序中对函数的调用。
当某对象收到一个消息时,
包含在该对象内的一些方法作出响
应。
方法
类似于面向过程程序设计的函数。然而,方法是对象
的一部分。
C++
的类是对
C
和
C++
结构类型的
扩充,
并且形成了面向对象程序设计所需要的抽象数
据类型。类
能包含紧密相关的一些条目,
它们共享一些属性。
更正式地说,
对象只不过是类
的实例。
最终,应该出现包含很多对象类型的类库,你能使用这些对象类型的实例去拼合程序代
码。
在你更详细地考察这些术语之前,
一个好的主意是熟悉与
C++
和面向对象程序设计
相关
的另外几个概念,如同下面几节所述的。
封装
封装
指
的是每个对象把它的成员数据和成员函数
(方法)
组合成单个结
构的方式。
图
3
-
1
举例说明了你如何能组合数据域和方法以建立对象。
数据域
方法
数据
成员函数
成员函数
成员函数
数据
成员函数
成员函数
数据
成员函数
图
3
-
1
为建立对象而组合的数据域和方法
典型地,一个对象的描述是一个
C+
+
类的一部分,
且包括对该对象内部
结构的描述、
该对象如何与其他对象相关,
以及把该对象的功能
细节和该类的外部相隔离的某种形式的保
护。
C++
类结构做到了所有这些。
在一个
C++
类中,你使用私有的、公共的和
/
或受保护的描述符来控制对象的功能细节。
在面向对象的程序设计中,
公共
(
public
)部分一般用于接口信息(方法)
,使得该类可在各
应用中重用
。
如果数据或方法被包含在公共部分,
它们在该类外部也可用。
类的
私有
部分把
数据或方法的可用性局限于该类本身。
包含数据或方法的
受保
护
部分被局限于该类和任何派
生子类。
类层次结构
C++
< br>类实际上用作创建对象的模板或模式。从类描述形成的对象都是该类的
实例
。开发
类层次结构是可能的,其中有一个主类和几个子类。在
C++
中,
做这事的
基础是
派生类
。
父类表示更一般化的任
务,
而派生子类执行一些特定的任务。
例如,
< br>早先讨论的林肯类也许
包含整个林肯系列公共的数据和方法,诸如引擎、检测仪表
、电池、制动能力和操纵。从父
类派生的子类,
诸如
Tour Car
、
Mark
< br>Ⅷ和
Continental
可能包含该类专用的一些款
项。
例如,
1995 Continental
是该系列中唯一具有主动悬架系统的汽车。
继承
面向对象程序设计中的
继承
使得一个类能继承某对象类的一些性质。
父
类用作派生类的
模式,
且能以几种方式被改变
< br>(在下一章中你将了解成员函数能被重载、
新的成员函数能被
添加,并且成员存取特权能被改变)
。如果某个对象从单个父类继承其属性,称为<
/p>
单继承
。
如果某个对象从多个父类继承属
性,
便称为
多继承
。
< br>继承是一个重要概念,
因为它使得无须
对代码做大的改变
就能重用类定义。继承鼓励重用代码,因为子类是对父类的扩充。
多态性
与类层次结构相关的另一个重
要的面向对象概念是公共消息能被发送到诸父类对象和
所有派生子类对象。按正式的术语
,这称为
多态性
。
< br>多态性使每个子类对象能以一种对其定义来说适当的方式对消息格式作出响应。
试
设想
收集数据的一个类层次结构。
父类可能负责收集某个个体的
姓名、
社会安全号、
职业和
雇佣年数,
那末你能使用子类来决定根据职业将添加什么附加信息。
一种情
况,
一个管
理职位会包括年薪,
而另一
种情况,
销售员职位会包括小时工资和回扣信息。因此,父
类收
集一切子类公共的通用信息,
而子类收集与特定工作描述相关的附加信息。
多态性
使得公共的数据收集消息能被发送到每个类。
父类和子类两者都以对该消息是恰当的方
式作出响应。多态性促进现有代码的可扩充性。
虚函数
多
态性赋予对象以当对象的精确类型还未知时响应来自例行程序之消息的能力。
在
C++
中这能力是
迟绑定
的结果。
使用迟绑定,
地址在运行时刻动态地确定,
而不是如同传统的编
译型语言在编译时刻静态地确定。这静态的(固定的
)方法往往称为
早绑定
。函数名被替换
为存储地址。
你使用
虚函数
来完成迟绑
定。
在随后的派生类将通过重定义函数之实现而重载
该函数时,
在父类中定义虚函数。当你使用虚函数时,消息不是直接传给对象,而是作为指
向对象的指针传送。
虚函数利用了地址信息表,
该表在运
行时刻使用构造符而被初始化。一个构造符每当
创建它的类的一个对象时被调用。
这里构造符的工作是把虚函数与地址信息表链接,
在编译
运转期间虚函数的地址是未知的;相反,
给出的是(在运行时刻确定的)
p>
地址表中将包含该
函数(入口)地址的位置。
3.4
JavaScript
教程
Java is designed to meet the
challenges of application development in the
context of heterogeneous, network-wide
distributed environments. Paramount among
these challenges is secure delivery of
applications that consume the minimum of
system
resources,
can
run
on
any
hardware
and
software
platform,
and
can
be
extended
dynamically.
Java
是为了解决在复杂的、大规
模分布式网络环境下开发应用程序的挑战而设计的。其中
最大的一个挑战是确保交付的程
序:占用最少的系统资源
,
并且能在任何硬件、软件平台下
p>
运行,能被动态扩展。
Java
originated
as
part
of
a
research
project
to
develop
advanced
software
for
a
wide variety of network devices and embedded
systems. The goal was to develop a
small, reliable, portable, distributed,
real-time operating platform. When the
project started, C++ was the language
of choice. But over time the difficulties
encountered with C++ grew to the point
where the problems could best be addressed
by
creating
an
entirely
new
language
platform.
Design
an
architecture
decisions
drew
from
a
variety
of
language
such
as
Eiffel,
SmallTalk,
Objective,
C,
and
Cedar/Mesa.
The result is a
language platform that has proven ideal for
developing secure,
distributed,
network
based
end-user
applications
in
environments
ranging
from
network-embedded devices to the World-
Wide-Web an the desktop.
Ja
va
最初只是一个为各种网络和嵌入式设备而研究的软件系统的一部分,这个系统的目标
是一个小的、可信赖的、可移植的,分布式的、实时的平台。最开始
C++
语言是这个平台的
首选。但随着时间的推移,
C++
出现了很多问题,有必要开发一个全新的语言平台。我们根
p>
据
Eiffel, SmallTalk, Objective,
C, and Cedar/Mesa
等语言来做出决策,结果是开发出
了一个理想的、
能在从嵌入式网络设备到万维网到桌面等各种环境下方便的开发
安全的、
分
布的、基于网络的应用程序的平台。
`The
design requirements of Java are driven by the
nature of the computing
environments in
which software must be deployed.
Java
的设计要求是由软件所部署的计算环境的本质决定的
.
The massive growth of the Internet and
the World-Wide Web leads us to a completely
new
way
of
looking
at
development
and
distribution
of
software.
To
live
in
the
world
of
electronic
commerce
and
distribution,
Java
technology
must
enable
the
development
of secure, high
performance, and highly robust applications on
multiple platforms
in heterogeneous,
distributed networks.
互联网和万
维网的快速发展带领我们用新的眼光去看待开发和发布软件。
在电子商务的时代,
Java
必须具有开发安全性、高效性、健壮的、大众的、能在多平台
和多样化、分布式网络
运行的程序。
Operating
on
multiple
platforms
in
heterogeneous
networks
invalidates
the
traditional schemes of
binary distribution , release, upgrade, patch, and
so on.
To
survive
in
this
jungle,
java
must
be
architecture
neutral,
portable,
and
dynamically adaptable.
为了能在异
构网络的多个平台上执行二进制发布、升级、修补等计划的环境中发展,
Java
必须是总体结构不带偏向性的、可移植的、且能动态地自适应的。
The java system that
emerged to meet there needs in simple, so it can
be easily
programmed
by
most
developers;
familiar,
so
that
current
developers
can
easily
learn
java;
object
oriented
,to
take
advantage
of
modern
software
development
methodologies
and
to
fit
into
distributed
client-server
application;
multithreaded,
for high
performance in applications that need to perform
multiple concurrent
activities , such
as multimedia; and interpreted ,for maximum
portability and
dynamic capabilities.
Java
系统的出现使得这些需求变
得简单,所以可以很容易的被大多数开发人员所使用;大
众的,所以现在的开发人员可以
很容易的学习
Java
;面对对象的,利用现代软件开发方法<
/p>
的优势以适应分布式客户端
-
服务器应用
程序;
多线程的,
用于高性能的执行多个并发活动,
如多媒体;解释型的,为了最大的可移植性和动态能力。
Together,
the
above
requirements
comprise
quite
a
collection
of
buzzwords,
so
let’s
examine some of them
and their respective benefits before going on.
总的来说,
上述包括相当多的专业术
语,
所以在继续之前先让我们来认识一下它们以及它们
所带来的
的各种好处。
What's
completely new is the manner in which java and its
run-time system have
combined them to
produce a flexible and powerful programming
system.
Java
和它在运
行时的系统能包含有良好的操作性以及强大的编译设计系统是一种全新的方
式。
Developing
your
applications
using
Java
results
in
software
that
is
portable
across
multiple
machine
architectures,
operating
systems,
and
graphical
user
interfaces,
secure,
and
high
performance.
With
Java,
your
job
as
a
software
developer
is
much
easier--you
focus
your
full
attention
on
the
end
goal
of
shipping
innovative
products on time, based on the solid
foundation of Java. The better way to develop
software is here, now, brought to you
by the Java language platform.
使用
Java
开发您的应用软件所带来的是可在多种机
器总体结构、操作系统和图形用户借口
间的移植,安全性和高性能。使用
Java
,你作为软件开发人员的工作室非常容易的
-
-
基于
Java
的基础您可以专注发展
和及时创新。
开发软件的最好方法在这里,
现在,
给您带来
Java
语言平台。
Very
dynamic languages like lisp, TCL, and SmallTalk
are often used for
prototyping. one of
the reasons for their success at this is that they
are very
robust---you don't have to
worry about freeing or corrupting memory.
非常具有生命力的语言如
lisp<
/p>
、
tcl
和
Sm
allTalk
常常用于充当原型构造技术。
他们在这取
得成功的其中一个原因是:他们非常强大,您不需要内存的释放或者损坏。
Similarly ,programmers can be
relatively fearless about dealing with memory when
programming
in
java
.the
garbage
collection
system
makes
the
programmer's
job
vastly
easier
;with
the
burden
of
memory
management
taken
off
the
programmer's
shoulders
,
storage allocation errors
go away.
同样的,程序员在使用
< br>Java
编程的时候可以不用过多担心存储问题。无用单元手机系统使
程序员的工作大为容易,卸下了程序员肩上存储管理的负担,存储分配错误不再发生。
Another
reason
commonly
given
that
like
lisp
,
TCl,
and
smalltalk
are
good
for
prototyping is that they don't require
you to pin down decision early on these
languages are semantically rich.
一般认为像
LISP
、
TCL
和
SmallTac
k
这样一些语言十分适合于原型法的另一理由,
是因为它
们不要求你受早期决定的约束
---
这样的语
言的语义是很丰富的。
Java
has
exactly
the
opposite
property
;
it
forces
you
to
make
explicit
choices
.
along
with these
choices come a lot of
assistance you can write method
invocations
and ,if you get
something wrong, you get told about it at compile
time . you don't
have to worry about
method invocations error.
J
ava
具有完全相反的性质,
它强制你做出明确的选择。
伴随着这些选择的是许多助理
---
如:
p>
你可以写一些方法的调用,
如果有错误,
你
会在编译时被告知。
您也不需要担心方法调用错
误。
4.1 summary of os
An operating system is the software
which acts as an interface between a user of
a computer and the computer hardware.
p>
操作系统是计算机用户和硬件的软件接口。
The
purpose of an operating system is to
provide an environment in which a user may
execute
program.
操作系统的目的是提供用户一个可以执行程序的环境。
The
primary
goal
of
an operating system is thus to make the computer
system convenient to use.
操
作
系统的主要目标因此是使计算机系统便于使用。
A
secondary
goal
is
to
use
the
computer
hardware in an
efficient way.
其次是高效地使用计算机硬件。
We
can view an operating system as a resource
allocator.
我们可以把操作系统看做
是一个资源分
配器。
A
computer
system
has
many
resources
which
may
be
required
to
solve
a
problem:
CPU
time,
memory
space,
file
storage,
input/output(I/O)
devices,
and
so <
/p>
on.
一个计算机系统拥有许多资源,因此需要去解决一些问题,
如
cpu
时间,内存空间,文
件存储,
输入输出设备等。
The
operating
system
acts
as
the
manager
of
these
resources
and
allocates
them
to
specific
programs
and
users
as
necessary
for
their
tasks.
操
作系统就像是资源管理员,
把资源分配给特定的程序和用户当它们工作
需要时。
Since
there
may
be
many,
possibly
conflicting,
requests
for
resources,
the
o/s
must
decide
which
requests
are
allocated
resources
to
operate
the
computer
system
fairly
and
efficiently.
因此有可能会有很多有可能产生冲
突的资源请求,操作系统必须决定分配资
源给哪个请求能使计算机系统合理和有效的运行
。
Early computers
were(physically) very large machines run from a co
nsole.
早期的计
算机是从控制台运行的体积非常大的机器
。
The
programmer
would
write
a
program
and
then
operate the program directly from the
operator
’
s console.
< br>程序员要写一条程序然
后直接从操作者的控制台操作程序。
Software
such
as
assemblers,
loaders,
and
compilers
improved
on
the
convenience
of
programming
the
system,
but
also
required
substantial
set-up time.
象汇编程序、装入程序及编译程序
这样的软件使系统软件编程更方便,但同
时也需要大量的启动时间。
To
reduce
the
setup
time,
operators
were
hired
and
similar
jobs
were
batched
together.[1]
为了能减少这些准备时间,操作者就
被雇佣,相似的作业
成批排在一起。
Batch systems allowed automatic job
sequencing by a resident monitor and improved
the overall utilization of the computer
greatly.
批处理系统通过一个常驻内存的监
控程序
允许自动的作业定序。
The computer no longer had to
wait for human operation.
这样计算机就不必再等待用户操作。
CPU
utilization
was
still
low,
however,
because
of
the slow speed of the I/O
devices relative to the CPU. Offline operation of
slow
devices was tried.
然而,<
/p>
CPU
使用率仍然不高,这是因为
I/O
设备的处理速度较
CPU
慢
导致的。
Buffering was
another approach to improving system performance
by overlapping the
input, output, and
computation of a single job.
缓冲机制是另一种提高
系统系能的方
法,它将一条作业的输入、输出和计算工作重叠交错进行。
Finally,
spooling
allowed
the
CPU
to overlap the input of one job with the
computation and output of other jobs.
最后
,伪脱机技术允许
CPU
将一条作业的输入和其他作业的计算输
出交错进行。
Spooling also
provides a pool of jobs which have been read and
are waiting to be
run.
伪脱机也为
那些已经被读入并且还在等待运行的作业提供一个作业池。
This
job
pool
supports
the
concept
of
multiprogramming.
这个作业池支持一种叫做多程序设计的概念。
With
multiprogramming, several jobs are kept in memory
at one time; the CPU is
switched back
and forth between them in order to increase CPU
utilization and to
decrease the total
real time needed to execute a job.
在这种多
程序设计技术中,多
个作业可以同时存放在内存中;
CPU
p>
在这些作业中来回切换控制,以至于增加
CPU
使用率和
减少执行一条作业的总时间。
Multiprogramming, which was developed
to improve performance, also allows time
sharing.
多道程序设计被开发来提高性能,也允许分时。
Time-shared
operating
systems
allow
many
users
(from
one
to
several
hundred)
to
use
a computer
system interactive at the same time.
分时
操作系统允许多个用户(从一个
到几百个)同时交互式地使用计算机系统。
As
the
system
switches
rapidly
from
one
user
to the next, each user is given the
impression that he has his own computer.
由
于系统迅速地从一个用户切换到下一个用户,
每一个用户
被给予一种他拥有自己的计算机的
印象。
Other
operating systems types include real-time systems
and multiprocessor
systems.
其他操作系统类型包括实时系统和多处理机系统。
A
real-time
system
is
often
used
as
control
de-vice
in
a
dedicated
application.
实
时系统通常被用作专用的应用的控制设备。
Sensors bring data to the computer.
传感器把数据带给计算机。
The
computer
must
analyze
the
data
and
possibly
adjust
controls
to
modify
the
sensor
inputs.
计算机必须分析数据,也可能调整控制去修改传感器的输入。
Systems,
which
control
scientific
experiments,
medical
computer
systems,
industrial
control
systems, and
some display
systems are real-time
systems.
< br>控制科学的实验,
医学的计算机系统,工业的控制系统和一些显示系统等系统都是
实时系统。
A real-time operating
system has well-defined fixed time constraints
.实时操作系
统有定义明确的固定的时间约束。
Processing must be done within the
defined constraints, or the system will fail.
处理必须在定义的约束中完成,否则系统将失败。
A multiprocessor system has
more than one CPU.
多处理机系统有不只一个
CPU
。
The
obvious
advantages
would
appear
to
be
greater
computing
power
and
reliability.
显著的优势好像是强大的计算能力和可靠性。
There
are
various
types
of
operating
systems
for
multiprocessors
and
multicomputers.
有各种各样的操作系统用于多处理机和多计算机。
It is more or less possible to
distinguish two kinds of operating systems for
multiple
CPU
systems:
Loosely
coupled,
such
as
network
operating
system
and
distributed o/s, and tightly coupled,
such as parallel o/s.
这或多或少可能区分两
种多
CPU
系统的操作系统:松耦合,
例如网络操作系统和分布式操作系统,
和紧耦合,
如并
行操作系统。
As
we
shall
see,
loosely
and
tightly-coupled
s/w
is
rought
analogous
to
loosely
and
tight-coupled h/w.
我们应该看到,松紧耦合软件大概类似于松紧耦合硬件。
The operating system must
ensure correct operation of the computer system. <
/p>
操作
系统必须确保改正计算机系统的操作。
To
prevent
user
programs
from
interfering
with
the
proper
operation
of
the
system,
the h/w was modified
to create two modes: user mode and monitor
mode[4].
为了阻
止用户程序干扰系统适当的操作,硬
件被修改成两种模式:用户模式和监控模式。
Various
instructions(such
as
I/O
instructions
and
halt
instructions)
are
priviledged and can only be executed in
monitor mode.
许多指令(例如
I/O
指令和中
断指令)是有特权的,只能在监控模式下被执行。
The memory in which the monitor
resides must also be protected from modification
by the user.
监控程序所在的内存也必须保护起来以防用户修改。
A
time
prevents
infinite
loops.
定时器可以防止死循环。
Once
these
changes
(dual
mode,
privileged
instructions,
memory
protection,
timer
interrupt)
have
been
made
to
the
basic
computer architecture, it is possible to write a
correct operating system.
一旦这些对基本计算机体系结
构的改变
(双模,
权限指令,
内存保护
,
定时器中断)
被做到,
这可能写成一
个改进的操作系统。
4.2
窗口管理程序
窗口管理程序管理那些
用来交换应用程序和用户之间信息的设备。
输出设备包括视频显
示器和声音合成器。输入设备包括键盘和指点器,诸如鼠标、操纵杆、控制球、或光笔。窗
口管理程序与输出设备的设备驱动程序交互把信息呈现给用户,
与输入设备的设备驱动
程序
交互获取表示用户正在输入信息的消息。
应用程序和脚本执
行引擎把表示成位图或
PostSript
表示法的图像传给窗
口管理程序,
窗口管理程序把这些图像呈现给用户。
窗口管理程
序把用
户通过输入设备输入的消息返回给应用程序和脚本执行引擎。
窗口管理程序已十分普及,
因为它们支持许多对终端用户
和应用程序开发者两者都十分
有用的特性。
< br>用户与多个进程交互。
窗口管理程序把窗口分配给每个进程。
如果每个进程与一个显示
在显示屏上的窗口相关,
那么多个
进程可以共享一个视频显示屏。
用户通过观看分配给进程
的窗口
之内容和向其窗口处于激活状态的进程发命令来观察进展
(<
/p>
即执行情况
)
和控制各进
程。
用户容易在应用程序之间移动信息。
窗口给用户提供了一种在应用程序之间传送信息
的方法。图
4<
/p>
-
1
举例说明了一个有
< br>3
个窗口的显示屏。一个窗口分配给正文编辑程序,另一
个分配给电子表格程序,
而第三个窗口分配给数据库程序。
在这
个例子中,
用户首先用数据
库应用程序从数据库检索某些数据。
然后用户从检索得到的数据中选择某些,
并把这些数据
移到第二个窗口中的电子表格程序。
电子表格应用程序计算合计和总计信
息,
然后用户把计
算结果移到分配给正文编辑程序的窗口。
p>
用户使用正文编辑程序把总计信息集成到正在用正
文编辑程序准备的
报告中。
用户访问远程应用程序。
一
些窗口管理程序能够通过通信系统把一个窗口分配给运行在
远程计算机上的一个进程。<
/p>
例如,
工作站的用户希望访问某台大型机上的数据库。
该用户请
求窗口管理程序创建一窗口,
在该窗口中
用户可以输入对那台大型机上的数据库管理系统的
请求。在该请求被处理后,窗口管理程
序在该窗口中显示从数据库管理系统来的结果。
用户对一个进
程有多个视图。
一些窗口管理程序可以把几个窗口分配给一个应用程序:
每个窗口把该应用的某个方面显示给用户。
多个窗口对用户可能是有用的,
p>
可提供该应用程
序的多方面视图。例如,在图
4
-
2
中,两个窗口已分配给一个计
划系统。一个窗口显示一图
形,展示在一个项目的各任务之间的优先关系。另一窗口显示
了每个任务完成的百分比。
用户接收事件。
< br>当一个进程发现用户应该知道的某些非正常事件,
该进程通知窗口管理
程序显示一个描述该事件的消息。用户将注意到该消息的出现,并采取适当的动作。
用窗口管理程序可以构造复杂的用户接口。
大多数窗
口管理程序都有程序库,包含各
种各样的、可重用的交互对象,这些对象可用来构造复杂
的用户接口。
终端独立性。
一些窗口
管理程序工作在一大类终端和工作站上,
并且对应用程序隐藏了这些
终端和工作站之间的差别。
终端独立性增加了应用程序对各种各样的终端和工作站的
可移植
性。
6.2
Carrier Frequencies and
Multiplexing
载波频率和多路复用
@ Computer
networks
that
use
a
modulated
carrier
wave
to
transmit
data
are similar to
television stations that use a modulated carrier
wave to
broadcast video.
modulated
已调制的
p>
使用调制载波发送数据的计算机网络和利用调制载波广播视频信息的电视台相
类似。
The
similarities
provide
the
intuition
needed
to
understand
a
fundamental
principle:
similarity
相似性
intuition
直观
这一相似性给理解下述基本原理提供了启示:
Two or more signals that use
different carrier frequencies can be
transmitted over a single medium
simultaneously without interference.
signal
信号
simultaneously
同时地
interference
干扰
两个或多个使用不同载波频率的信号可以在单一介质上同时传输而互不干
扰。
@ To understand
the principle, consider how television
transmission
works.
为理解这一原理,考虑(有线)电视传输是如何工作的。
Each
television
station
is
assigned
a
channel
number
on
which
it
broadcasts a signal.
channel
频道
每个电视台都分配一个频道号,它在该频道上广播信号。
In fact, a channel
number is
merely
shorthand for the
frequency at which
the
station's carrier oscillates.
shorthand
速记
oscillate
振荡
事实上
,
频道号就是电视台载波用的振荡频率的速记。
To
receive
a
transmission,
a
television
receiver
must
be
tuned
to
the
same
frequency as the transmitter.
tune to
调谐到
为接收一个频道传输,电视接收器必须调谐到与发送器相同的频率。
More important, a given city can
contain many television stations that
all broadcast on separate frequencies
simultaneously.
更重要的是,一个城市可以有许多电视台,它们彼此
在不同的频率上同时广播。
A receiver
selects one to receive at any time.
一个接收器在任一时间选择接收其中一个。
@ Cable television
illustrates that the principle applies to many
signals traveling across a wire.
有线电视这一例子说明了以上原理应用于许多信号在一根导线上同时传输的情
况。
Although
a
cable
subscriber
may
have
only
one
physical
wire
that
connects
to
the
cable
company,
the
subscriber
receives
many
channels
of
information
simultaneously.
虽然一个有线电视用户可能只有一根线连向有线电视公司,
但用
户可同时收到许
多频道的信息。
The
signal
for
one
channel
does
not
interfere
with
the
signal
for
another.
一个频道中的信号不会与另一频道中的信号相互干扰。
@ Computer networks use
the principle of separate channels to permit
multiple communications to share a
single, physical connection.
permit
允许
计算机网络使用分离频道的原理使多个通信共享单根物理连线。
Each sender transmits a signal using a
particular carrier frequency.
每个发送器使用一个特定载波频率传输信号。
A receiver configured to accept a
carrier at a given frequency will not
be affected by signals sent at other
frequencies.
一个接收器被设置成接收给定频率的载波,
它将不会受其它频率信号的影响
(或
干扰)
。
All
carriers
can
pass
over
the
same
wire
at
the
same
time
without
interference.
所有载波可在同一时间通过同一导线而互不干扰。
Frequency Division
Multiplexing
频分多路复用
@ Frequency division
multiplexing(FDM) is the technical term applied
to a network system that uses multiple
carrier frequencies to allow
independent signals to travel through a
medium.
频分多路复用(
FDM
)是使用多个载波频率在一个介质中同时传输多个独立信号
的计算机网络系统术语。<
/p>
FDM
technology
can
be
used
when
sending
signals
over
wire,
RF,
or
optical
fiber.
当通
过导线、
RF
或光纤发送信号时便可使用
FDM
技术。
Figure
6-1 illustrates the concept, and shows the
hardware components
needed for FDM.
图
6-1
说明了这一概念并显示了
FDM
所需的硬件部件。
@ In
theory,
as
long
as
each
carrier
operates
at
a
different
frequency
than the others, it remains
independent.
理论上,工作在不同频率上的载波将保持相互独立。
In
practice,
however,
two
carriers
operating
at
almost
the
same
frequency
or
at exact multiples of a frequency can interfere
with one another.
但实际上,两个频率相近或频率成整倍的载波会彼此干扰。
To avoid problems, engineers who design
FDM network systems choose a
minimum
separation between the carriers.
为了避免这些
问题,
设计
FDM
网络系统的工程师们
在各载波之间选择一个最起码
-
-
-
-
-
-
-
-
-
上一篇:三年级英语演讲稿带翻译
下一篇:高三英语小作文【精选】