计算机系统概论基本知识

目录

chapter0

chapter1

 binary system

chapter2

chapter3

chapter4

chapter5

Pseudo-Code (or Program Design Language)

way to use fuction

 Algorithm Efficiency

Proof of correctness

chapter6

chapter7

chapter8

Basic Data Structures

 data structures

Related Concepts

Storing Arrays


chapter0

A representation of an algorithm is called a program.
算法的表示称为程序。
The process of developing a program, encoding it in machine-compatible form, and inserting
it into a machine is called programming.

开发程序的过程,以机器兼容的形式编码它,并插入它进入一台机器叫做编程。

Programs, and the algorithms they represent, are collectively referred to as software, in contrast to the machinery itself, which is known as hardware. 
程序,以及它们所代表的算法,被统称为软件,与机器本身形成鲜明对比,即硬件。

chapter1

A device that produces the output of a Boolean operation when given the operation’s input values is called a gate.
当给定操作的输入值称为栅极时,产生布尔操作输出的设备。
Gates provide the building blocks from which computers are constructed.One important step in this direction is depicted in the circuit in Figure 1.3. This is a particular example from a collection of circuits known as a flip-flop.
门提供了建造计算机的单元。图1.3中描述了这个方向的一个重要步骤。这是一个特定的例子,从一个被称为触发器的电路集合。
A technology known as very large-scale integration (VLSI), which allows millions of electrical components to be constructed on a wafer (called a chip ), is used to create miniature devices containing millions of flip-flops along with their controlling circuitry. Consequently, these chips are used as abstract tools in the construction of computer systems. In fact, in some cases VLSI is used to create an entire computer system on a single chip.
一种被称为超大规模集成(VLSI)的技术,允许在一块晶片(称为芯片)上构造数百万个电子元件,被用来制造包含数百万个触发器及其控制电路的微型设备。因此,这些芯片被用作构建计算机系统的抽象工具。事实上,在某些情况下,VLSI被用来在单个芯片上创建一个完整的计算机系统。
For the purpose of storing data, a computer contains a large collection of circuits (such as flip-flops), each capable of storing a single bit. This bit reservoir is known as the machine’s main memory.
为了存储数据,计算机包含大量的电路(例如触发器),每一个都能存储一个比特。这个位储层被称为机器的主存储器。
A computer’s main memory is organized in manageable units called cells, with a typical cell size being eight bits. (A string of eight bits is called a byte.
计算机的主存储器是由称为单元的可管理单元组织起来的,单元的典型大小为8位。(由8位组成的字符串称为字节。

The left end of this row is called the high-order end, and the right end is called the low-order end.
这一行的左端称为高阶端,右端称为低阶端。
The left most bit is called either the high-order bit or the most significant bit in reference to the fact that if the contents of the cell were interpreted as representing a numeric value, this bit would be the most significant digit in the number. Similarly, the rightmost bit is referred to as the low-order bit or the least significant bit.
最左边的位被称为高阶位或最高有效位,因为如果单元格的内容被解释为表示一个数值,那么这个位将是数字中的最高有效位。类似地,最右边的位称为低阶位或最低有效位。
To identify individual cells in a computer’s main memory, each cell is assigned a unique “name,” called its address.
为了识别计算机主存储器中的各个单元,给每个单元分配一个唯一的“名称”,称为其地址
Because a computer’s main memory is organized as individual, addressable cells, the cells can be accessed independently as required. To reflect the ability to access cells in any order, a computer’s main memory is often called random access memory (RAM). This random access feature of main memory is in stark contrast to the mass storage systems that we will discuss in the next section, in which long strings of bits are manipulated as amalgamated blocks.
由于计算机的主存储器是作为单独的、可寻址的单元组织起来的,这些单元可以根据需要独立地访问。为了反映以任何顺序访问单元的能力,计算机的主存储器通常称为随机访问存储器(RAM)。主存储器的这种随机访问特性与我们将在下一节讨论的大容量存储系统形成了鲜明的对比,在大容量存储系统中,长串的位元被当作合并的块来处理。
In recognition of this volatility, computer memory constructed from such technology is often called dynamic memory, leading to the term DRAM (pronounced “DEE–ram”) meaning Dynamic RAM. Or, at times the term SDRAM (pronounced “ES-DEE-ram”), meaning Synchronous DRAM, is used in reference to DRAM that applies additional techniques to decrease the time needed to retrieve the contents from its memory cells.
由于认识到这种波动性,由这种技术构建的计算机存储器通常被称为动态存储器,因此DRAM(读作“DEE-ram”)一词的意思就是动态RAM。或者,有时术语SDRAM(发音为ES-DEE-ram),意思是同步DRAM,用于参考DRAM,它应用额外的技术来减少从其存储单元检索内容所需的时间。
Due to the volatility and limited size of a computer’s main memory, most computers have additional memory devices called mass storage (or secondary storage) systems, including magnetic disks, CDs, DVDs, magnetic tapes, flash drives, and solid-state disks (all of which we will discuss shortly). The advantages of mass storage systems over main memory include less volatility, large storage capacities, low cost, and in many cases, the ability to remove the storage medium from the machine for archival purposes. A major disadvantage of magnetic and optical mass storage systems is that they typically require mechanical motion and therefore require significantly more time to store and retrieve data than a machine’s main memory, where all activities are performed electronically. Moreover, storage systems with moving parts are more prone to mechanical failures than solid state systems.
由于计算机主存储器的易挥发性和有限的大小,大多数计算机都有称为大容量存储(或次要存储)系统的额外存储设备,包括磁盘、cd、dvd、磁带、闪存驱动器和固态磁盘(我们将很快讨论所有这些)。与主存储器相比,大容量存储系统的优点包括更少的波动性、更大的存储容量、更低的成本,并且在许多情况下,还可以将存储介质从机器中移除以进行归档。磁性和光学海量存储系统的一个主要缺点是,它们通常需要机械运动,因此需要比机器主存储器更多的时间来存储和检索数据,而在主存储器中所有的活动都是电子执行的。此外,带有移动部件的存储系统比固态系统更容易发生机械故障。
The most common example in use today is the magnetic disk or hard disk drive (HDD), in which a thin spinning disk with magnetic coating is used to hold data (Figure 1.9). Read/write heads are placed above and/or below the disk so that as the disk spins, each head traverses a circle, called a track. In many cases, a disk storage system consists of several disks mounted on a common spindle, one on top of the other, with enough space for the read/write heads to slip between the platters. In such cases, the read/write heads move in unison. Each time the read/write heads are repositioned, a new set of tracks—which is called a cylinder —becomes accessible.
今天最常用的例子是磁盘或硬盘驱动器(HDD),其中使用一个带有磁性涂层的薄旋转磁盘来保存数据(图1.9)。读/写磁头放在磁盘的上方和/或下方,这样当磁盘旋转时,每个磁头穿过一个称为磁道的圆。在许多情况下,磁盘存储系统由安装在一个公共主轴上的多个磁盘组成,一个在另一个上面,有足够的空间让读/写磁头在盘片之间滑动。在这种情况下,读写头会一致移动。每次读取/写入磁头被重新定位时,就会有一组新的轨道(称为圆柱)被访问。
Since a track can contain more information than we would normally want to manipulate at any one time, each track is divided into small arcs called sectors on which information is recorded as a continuous string of bits. All sectors on a disk contain the same number of bits (typical capacities are in the range of 512 bytes toa few KB), and in the simplest disk storage systems each track contains the samenumber of sectors. Thus, the bits within a sector on a track near the outer edge of the disk are less compactly stored than those on the tracks near the center, since the outer tracks are longer than the inner ones. In contrast, in high-capacity disk storage systems, the tracks near the outer edge are capable of containing significantly more sectors than those near the center, and this capability is often used by applying a technique called zoned-bit recording. Using zoned-bit recording, several adjacent tracks are collectively known as zones, with a typical disk containing approximately 10 zones. All tracks within a zone have the same number of sectors, but each zone has more sectors per track than the zone inside of it. In this manner, efficient use of the entire disk surface is achieved. Regardless of the details, a disk storage system consists of many individual sectors, each of which can be accessed as an independent string of bits.
由于磁道包含的信息比我们通常想要在任何时候操作的信息都要多,每个磁道被划分为称为扇区的小弧,在扇区上信息被记录为一个连续的比特串。磁盘上的所有扇区包含相同数量的位(典型的容量在512字节到几KB的范围内),并且在最简单的磁盘存储系统中,每个磁道包含相同数量的扇区。因此,由于外层磁道比内部磁道长,靠近磁盘外缘的磁道上扇区内的位存储的紧凑程度要低于靠近中心的磁道上的位。相反,在大容量磁盘存储系统中,靠近外缘的磁道比靠近中心的磁道能够包含更多的扇区,这种能力通常通过应用一种称为分区位记录的技术来使用。使用分区位记录,几个相邻的磁道统称为分区,一个典型的磁盘大约包含10个分区。区域内的所有磁道都有相同数量的扇区,但是每个区域每个磁道的扇区比其中的区域多。通过这种方式,可以有效地利用整个磁盘表面。不管细节如何,磁盘存储系统由许多单独的扇区组成,每个扇区都可以作为一个独立的位串访问。
seek time :the time required to move the read/write heads from one track to another
寻道时间:将读写磁头从一个磁道移动到另一个磁道所需的时间
rotation delay or latency time :half the time required for the disk to make a complete rotation, which is the average amount of time required for the desired data to rotate around to the read/write head once the head has been positioned over the desired track
旋转延迟或延迟时间:磁盘完成旋转所需时间的一半,即当磁头定位在所需磁道上时,所需数据旋转到读写磁头所需的平均时间
access time :the sum of seek time and rotation delay
访问时间:寻道时间和旋转时延之和
transfer rate :the rate at which data can be transferred to or from the disk
传输速率:数据传输到磁盘或从磁盘传输的速率
Note that in the case of zone-bit recording, the amount of data passing a read/write head in a single disk rotation is greater for tracks in an outer zone than for an inner zone, and therefore the data transfer rate varies depending on the portion of the disk being used.
请注意,在zone-bit记录的情况下,在单个磁盘旋转中通过读/写头的数据量在外部区域的磁道中要大于内部区域,因此数据传输速率取决于所使用的磁盘部分。
Magnetic storage technologies that are now less widely used include magnetic tape, in which information is recorded on the magnetic coating of a thin plastic tape wound on reels, and floppy disk drives, in which single platters with a magnetic coating are encased in a portable cartridge designed to be readily removed from the drive.
磁存储技术,现在广泛使用的包括磁带、信息记录在磁层的一层薄薄的塑料带缠绕在卷,和软盘驱动器,单盘与一个磁性涂层是装在便携盒设计成容易从驱动器中删除。
Flash memory technology has the potential of alleviating this drawback. In a flash memory system, bits are stored by sending electronic signals directly to the storage medium where they cause electrons to be trapped in tiny chambers of silicon dioxide, thus altering the characteristics of small electronic circuits. Since these chambers are able to hold their captive electrons for many years without external power, this technology is excellent for portable, nonvolatile data storage.
闪存技术有可能缓解这一缺点。在闪存系统中,比特是通过直接向存储介质发送电子信号来存储的,在存储介质中,电子被困在二氧化硅的小腔中,从而改变了小型电子电路的特性。由于这些腔室能够在没有外部电源的情况下保持其捕获的电子多年,这项技术非常适合便携式、非易失性的数据存储。
Flash memory devices called flash drives, with capacities of hundreds of GBs, are available for general mass storage applications
.闪存设备称为闪存驱动器,具有数百gb的容量,可用于一般的大容量存储应用。
Larger flash memory devices called SSDs (solid-state disks) are explicitly designed to take the place of magnetic hard disks. SSDs compare favorably to hard disks in their resilience to vibrations and physical shock, their quiet operation (due to no moving parts), and their lower access times. SSDs remain more expensive than hard disks of comparable size and thus are still considered a high-end option when buying a computer. SSD sectors suffer from the more limited lifetime of all flash memory technologies, but the use of wear-leveling techniques can reduce the impact of this by relocating frequently altered data blocks to fresh locations on the drive. 
被称为ssd(固态硬盘)的更大的闪存设备被明确地设计来取代磁碟。与硬盘相比,ssd在抗振动和物理冲击方面更有优势,其操作安静(由于没有移动部件),以及更低的访问时间。ssd仍然比同等大小的硬盘更贵,因此在购买计算机时仍被视为高端选择。SSD扇区的寿命比所有闪存技术都要短,但是使用磨损均衡技术可以通过将频繁更改的数据块重新定位到驱动器上的新位置来减少这种影响
Another application of flash technology is found in SD (Secure Digital) memory cards (or just SD Card). These provide up to two GBs of storage and are packaged in a plastic rigged wafer about the size a postage stamp (SD cards are also available in smaller mini and micro sizes), SDHC (High Capacity) memory cards can provide up to 32 GBs and the next generation SDXC (Extended Capac ity) memory cards may exceed a TB.
闪存技术的另一个应用是在SD(安全数字)存储卡(或仅仅是SD卡)中。这些提供2 gb的存储和打包在一个塑料操纵晶片大小邮票(SD卡也可以在较小的小型和微型大小),SDHC记忆卡(大容量)可以提供32 GBs和下一代SDXC(扩展能力)记忆卡可能超过一个结核病。

 binary system

one’s complement notation:如果是正整数,为原二进制码。如果是负整数,将二进制数反转(包括符号位),得到的数即为原二进制的一的补数(ones' complement)。若某一位为0,则使其变为1,反之亦然。

two’s complement notation:如果是正数, 补码与原码一样。如果是负数,在反码的基础上+1。

excess notation:2的n-1次方+原数(与two’s complement notation就符号位相反)

floating-point notation:sign bite(符号位)+exponent(用excess notation表示, 正数:将基数向右移动; 负数:将基数向左移动 )+mantissa(如果超出要去除lsm——最后一位)
One means of representing an image is to interpret the image as a collection of dots, each of which is called a pixel, short for “picture element.” The appearance of each pixel is then encoded and the entire image is represented as a collection of these encoded pixels. Such a collection is called a bit map.
表示图像的一种方法是将图像解释为点的集合,每个点称为像素,即“图像元素”的缩写。然后对每个像素的外观进行编码,并将整个图像表示为这些编码像素的集合。这样的集合称为位图。
For the purpose of storing or transferring data, it is often helpful (and sometimes mandatory) to reduce the size of the data involved while retaining the underlying information. The technique for accomplishing this is called data compression.
为了存储或传输数据,在保留基础信息的同时减少所涉及的数据的大小通常是有帮助的(有时是强制性的)。实现这一点的技术称为数据压缩。
In cases where the data being compressed consist of long sequences of the same value, the compression technique called run-length encoding, which is a lossless method, is popular.
在被压缩的数据由相同值的长序列组成的情况下,称为游程编码的压缩技术是一种无损方法,它很受欢迎。
The parity system just described is called odd parity, because we designed our system so that each correct pattern contains an odd number of 1s. Another technique is called even parity.
刚才描述的奇偶校验系统被称为奇偶校验,因为我们设计的系统使每个正确的图案包含一个奇数个1。另一种技术叫做偶奇偶校验。

chapter2

The circuitry in a computer that controls the manipulation of data is called the central processing unit, or CPU (often referred to as merely the processor).
计算机中控制数据操作的电路称为中央处理单元(central processing unit,简称CPU)(通常简称处理器)。
The CPUs found in today’s desktop computers and notebooks are packaged as small flat squares (approximately two inches by two inches) whose connecting pins plug into a socket mounted on the machine’s main circuit board (called the motherboard). In smartphones, mini-notebooks, and other Mobile Internet Devices (MID), CPUs are around half the size of a postage stamp. Due to their small size, these processors are called microprocessors.
今天的台式电脑和笔记本电脑中的cpu被包装成正方形(大约2英寸乘2英寸),其连接引脚插入安装在机器主电路板(称为主板)上的插座。在智能手机、迷你笔记本电脑和其他移动互联网设备(MID)中,cpu大约只有邮票的一半大小。由于体积小,这些处理器被称为微处理器。
A CPU consists of three parts:the arithmetic/logic unit, which contains the circuitry that performs operations on data (such as addition and subtraction); the control unit, which contains the circuitry for coordinating the machine’s activities; and the register unit, which contains data storage cells (similar to main memory cells), called registers, that are used for temporary storage of information within the CPU.
CPU由三部分组成:算术/逻辑单元,它包含对数据进行运算(如加减)的电路;控制单元,包含协调机器活动的电路;和寄存器单元,它包含数据存储单元(类似于主存储器单元),称为寄存器,用于在CPU内临时存储信息。
Some of the registers within the register unit are considered general-purpose registers, whereas others are special-purpose registers.
寄存器单元内的一些寄存器被认为是通用寄存器,而另一些则是专用寄存器。
For the purpose of transferring bit patterns, a machine’s CPU and main memory are connected by a collection of wires called a bus.
为了传输位模式,机器的CPU和主存储器由一组称为总线的导线连接起来
The idea of storing a computer’s program in its main memory is called the stored-program concept and has become the standard approach used today—so standard, in fact, that it seems obvious.
把计算机程序存储在主存储器中的想法被称为存储程序的概念,它已经成为今天使用的标准方法——事实上,它是如此的标准,以至于看起来是显而易见的。
This collection of instructions along with the encoding system is called the machine language. An instruction expressed in this language is called a machine-level instruction or, more commonly, a machine instruction.
这种指令集合连同编码系统被称为机器语言。用这种语言表示的指令称为机器级指令,或者更常见的是机器指令。
Reduced instruction set computer (RISC) is that a CPU should be designed to execute a minimal set of machine instructions. The argument in favor of RISC architecture is that such a machine is efficient, fast, and less expensive to manufacture.
精简指令集计算机(RISC)是指CPU应该被设计用来执行最小的机器指令集。支持RISC架构的论点是,这样的机器是高效的,快速的,而且制造成本更低。
Others argue in favor of CPUs with the ability to execute a large number of complex instructions, even though many of them are technically redundant. The result of this approach is known as a complex instruction set computer (CISC).
另一些人则认为cpu应该具备执行大量复杂指令的能力,尽管从技术上讲,许多指令是多余的。这种方法的结果被称为复杂指令集计算机(CISC)。
An important group of instructions within the data transfer category consists of the commands for communicating with devices outside the CPU-main memory context (printers, keyboards, display screens, disk drives, etc.). Since these instructions handle the input/output (I/O) activities of the machine, they are called I/O instructions and are sometimes considered as a category in their own right. 
数据传输类中的一组重要指令由用于与cpu -主存上下文之外的设备(打印机、键盘、显示屏、磁盘驱动器等)通信的命令组成。因为这些指令处理机器的输入/输出(I/O)活动,所以它们被称为I/O指令,有时被认为是它们自己的一类。
To understand how the overall execution process takes place, it is necessary to consider two of the special purpose registers within the CPU: the instruction register and the program counter.
为了理解整个执行过程是如何发生的,有必要考虑CPU中两个特殊用途的寄存器:指令寄存器和程序计数器。
The CPU performs its job by continually repeating an algorithm that guides it through a three-step process known as the machine cycle.
CPU通过不断重复一个算法来完成它的工作,这个算法通过一个被称为机器周期的三步过程来指导它。

Technologies to increase throughput:
提高输出量的技术:
Pipelining: Overlap steps of the machine cycle
流水线:机器循环的重叠步骤
Parallel Processing : Use multiple processors simultaneously
并行处理:同时使用多个处理器
SISD (single-instruction stream, single-data stream)→ No parallel processing

SISD(单指令流,单数据流)→没有并行处理

MIMD (Multiple-instruction stream, Multiple-data stream)→ Different programs, different data

MIMD(多指令流,多数据流)→ 不同的程序,不同的数据

SIMD (single-instruction stream, Multiple-data stream)→ Same program, different data

SIMD(单指令流,多数据流)→同一个程序,不同的数据

chapter3

The execution of each program, called a job, was handled as an isolated activity—the machine was prepared for executing the program, the program was executed, and then all the tapes, punched cards, etc. had to be retrieved before the next program preparation could begin.
每个程序的执行,称为一个作业,被作为一个独立的活动处理——机器为执行程序做好了准备,程序被执行,然后所有的磁带、穿孔卡片等,必须在开始下一个程序准备之前取回。
This was the beginning of batch processing—the execution of jobs by collecting them in a single batch, then executing them without further interaction with the user.
这是批处理的开始——通过将作业收集到单个批处理中来执行作业,然后在不与用户进行进一步交互的情况下执行它们。
One early development was the separation of users and equipment, which eliminated the physical transition of people in and out of the computer room. For this purpose a computer operator was hired to operate the machine. Anyone wanting a program run was required to submit it, along with any required data and special directions about the program’s requirements, to the operator and return later for the results. The operator, in turn, loaded these materials into the machine’s mass storage where a program called the operating system could read and execute them one at a time. This was the beginning of batch processing—the execution of jobs by collecting them in a single batch, then executing them without further interaction with the user.
一个早期的发展是用户和设备的分离,这消除了人进出计算机房间的物理转换。为此,雇了一个电脑操作员来操作这台机器。任何想要运行程序的人都需要将程序提交给操作人员,连同任何所需的数据和关于程序要求的特殊说明,然后返回结果。接着,操作员将这些材料装入机器的大容量存储器中,一个称为操作系统的程序可以一次读取并执行它们。这是批处理的开始——通过将作业收集到单个批处理中来执行作业,然后在不与用户进行进一步交互的情况下执行它们。
A queue is a storage organization in which objects (in this case, jobs) are ordered in first-in, first-out (abbreviated FIFO and pronounced “FI-foe”) fashion.
队列是一种存储组织,其中对象(在本例中是作业)按照先进先出(缩写为FIFO,发音为“FI-foe”)的方式进行排序。
To accommodate these needs, new operating systems were developed that allowed a program being executed to carry on a dialogue with the user through remote terminals—a feature known as interactive processing.
为了满足这些需求,新的操作系统被开发出来,允许一个正在执行的程序通过远程终端与用户进行对话,这种特性被称为交互处理。

In a sense, the computer is forced to execute tasks under a deadline, a process that became known as real-time processing in which the actions performed are said to occur in real-time.

从某种意义上说,计算机被迫在一个期限内执行任务,这个过程后来被称为实时处理,在这个过程中,所执行的操作被称为实时发生的。

The solution to this problem was to design operating systems that provided service to multiple users at the same time: a feature called time-sharing. One means of implementing time-sharing is to apply the technique called multiprogramming in which time is divided into intervals and then the execution of each job is restricted to only one interval at a time. At the end of each interval, the current job is temporarily set aside and another is allowed to execute during the next interval. By rapidly shuffling the jobs back and forth in this manner, the illusion of several jobs executing simultaneously is created. Depending on the types of jobs being executed, early time-sharing systems were able to provide acceptable real-time processing to as many as 30 users simultaneously. Today, multiprogramming techniques are used in single-user as well as multiuser systems, although in the former the result is usually called multitasking. That is, time-sharing refers to multiple users sharing access to a common computer, whereas multitasking refers to one user executing numerous tasks simultaneously.
这个问题的解决方案是设计能够同时为多个用户提供服务的操作系统:这一特性被称为分时。实现分时的一种方法是应用称为多道程序设计的技术,在这种技术中,时间被划分为多个间隔,然后每个作业的执行被限制在一个时间间隔内。在每个间隔结束时,当前作业将被暂时搁置,并允许在下一个间隔期间执行另一个作业。通过以这种方式快速地来回移动作业,就会产生多个作业同时执行的错觉。根据正在执行的作业的类型,早期的分时系统能够同时为多达30个用户提供可接受的实时处理。今天,多程序设计技术被用于单用户和多用户系统,尽管前者的结果通常被称为多任务处理。也就是说,分时指的是多个用户共享对一台普通计算机的访问,而多任务处理指的是一个用户同时执行多个任务。
The development of multiprocessor machines has led to operating systems that provide time-sharing/ multitasking capabilities by assigning different tasks to different processors as well as by sharing the time of each single processor. These operating systems must wrestle with such problems as load balancing (dynamically allocating tasks to the various processors so that all processors are used efficiently) as well as scaling (breaking tasks into a number of subtasks compatible with the number of processors available).
多处理器机器的发展使得操作系统通过将不同的任务分配给不同的处理器以及共享每个处理器的时间来提供分时/多任务处理能力。这些操作系统必须处理负载平衡(将任务动态分配给各种处理器,以便有效地使用所有处理器)和可伸缩性(将任务分解为与可用处理器数量相匹配的许多子任务)等问题。
Still another direction of research in operating systems focuses on devices that are dedicated to specific tasks such as medical devices, vehicle electronics, home appliances, cell phones, or other hand-held computers. The computer systems found in these devices are known as embedded systems.
操作系统的另一个研究方向是专注于用于特定任务的设备,如医疗设备、车辆电子设备、家用电器、手机或其他手持电脑。在这些设备中发现的计算机系统被称为嵌入式系统。
Application software consists of the programs for performing tasks particular to the machine’s utilization. A machine used to maintain the inventory for a manufacturing company will contain different application software from that found on a machine used by an electrical engineer. Examples of application software include spreadsheets, database systems, desktop publishing systems, accounting systems, program development software, and games.
应用软件由执行与机器利用率有关的特定任务的程序组成。制造公司用于维护库存的机器将包含不同于电气工程师使用的机器上的应用软件。应用软件的例子包括电子表格、数据库系统、桌面出版系统、会计系统、程序开发软件和游戏。
In contrast to application software, system software performs those tasks that are common to computer systems in general. In a sense, the system software provides the infrastructure that the application software requires, in much the same manner as a nation’s infrastructure (government, roads, utilities, financial institutions, etc.) provides the foundation on which its citizens rely for their individual lifestyles.
与应用软件相比,系统软件执行的任务通常是计算机系统所共有的。在某种意义上,系统软件提供了应用软件所需的基础设施,就像一个国家的基础设施(政府、道路、公用事业、金融机构等)为其公民的个人生活方式提供基础一样。
In order to perform the actions requested by the computer’s users, an operating system must be able to communicate with those users. The portion of an operating system that handles this communication is often called the user interface.
为了执行计算机用户所要求的操作,操作系统必须能够与这些用户进行通信。操作系统中处理这种通信的部分通常称为用户界面。
Older user interfaces,called shells,communicated with users through textual messages using a keyboard and monitor screen.
旧的用户界面称为shell,通过键盘和显示器屏幕通过文本消息与用户通信。
More modern systems perform this task by means of a graphical user interface (GUI—pronounced “GOO–ee”) in which objects to be manipulated, such as files and programs, are represented pictorially on the display as icons.
更现代的系统通过图形用户界面(gui -发音为“gooe - ee”)来执行这项任务,在图形用户界面中,要操作的对象,如文件和程序,在显示器上以图形化的图标表示。

An important component within today’s GUI shells is the window manager, which allocates blocks of space on the screen, called windows, and keeps track of which application is associated with each window.
今天GUI shell中的一个重要组件是窗口管理器,它在屏幕上分配称为窗口的空间块,并跟踪哪个应用程序与每个窗口相关联。
In contrast to an operating system’s user interface, the internal part of an operating system is called the kernel. An operating system’s kernel contains those software components that perform the very basic functions required by the computer installation. One such unit is the file manager, whose job is to coordinate the use of the machine’s mass storage facilities. More precisely, the filemanager maintains records of all the files stored in mass storage, including whereeach file is located, which users are allowed to access the various files, and which portions of mass storage are available for new files or extensions to existing files. These records are kept on the individual storage medium containing the related files so that each time the medium is placed online, the file manager can retrieve them and thus know what is stored on that particular medium.
与操作系统的用户界面相比,操作系统的内部部分称为内核。操作系统的内核包含那些执行计算机安装所需要的基本功能的软件组件。其中一个这样的单元是文件管理器,它的工作是协调机器的大量存储设施的使用。更准确地说,file manager维护存储在大容量存储中的所有文件的记录,包括每个文件的位置、允许哪些用户访问各种文件,以及大容量存储中的哪些部分可用于新文件或现有文件的扩展名。这些记录保存在包含相关文件的单个存储媒体上,因此每次将媒体置于在线状态时,文件管理器就可以检索它们,从而知道在该特定媒体上存储了什么。
For the convenience of the machine’s users, most file managers allow files to be grouped into a bundle called a directory or folder. This approach allows a user to organize his or her files according to their purposes by placing related files in the same directory. Moreover, by allowing directories to contain other directories, called subdirectories, a hierarchical organization can be constructed.
为了方便计算机用户,大多数文件管理器允许将文件分组到一个称为目录或文件夹的包中。通过将相关文件放置在相同的目录中,用户可以根据文件的目的来组织文件。此外,通过允许目录包含其他目录(称为子目录),可以构建层次结构组织。
A chain of directories within directories is called a directory path. Paths are often expressed by listing the directories along the path separated by slashes.
目录中的目录链称为目录路径。路径通常是沿着用斜杠分隔的路径列出目录。
Another component of the kernel consists of a collection of device drivers, which are the software units that communicate with the controllers (or at times, directly with peripheral devices) to carry out operations on the peripheral devices attached to the machine. Each device driver is uniquely designed for its particular type of device (such as a printer, disk drive, or monitor) and translates generic requests into the more technical steps required by the device assigned to that driver.
内核的另一个组件由一组设备驱动程序组成,这些驱动程序是与控制器(有时是直接与外围设备)通信的软件单元,用于对附加到机器上的外围设备进行操作。每个设备驱动程序都是为其特定类型的设备(如打印机、磁盘驱动器或监视器)设计的,并将通用请求转换为分配给该驱动程序的设备所需的更技术性的步骤。
Still another component of an operating system’s kernel is the memory manager, which is charged with the task of coordinating the machine’s use of main memory.The task of the memory manager is complicated further when the total main memory space required exceeds the space actually available in the computer. In this case the memory manager may create the illusion of additional memory space by rotating programs and data back and forth between main memory and mass storage (a technique called paging ). Suppose, for example, that a main memory of 8GB is required but the computer only has 4GB. To create the illusion of the larger memory space, the memory manager reserves 4GB of storage space on a magnetic disk. There it records the bit patterns that would be stored in main memory if main memory had an actual capacity of 8GB. This data is divided into uniform sized units called pages, which are typically a few KB in size. Then the memory manager shuffles these pages back and forth between main memory and mass storage so that the pages that are needed at any given time are actually present in the 4GB of main memory. The result is that the computer is able to function as though it actually had 8GB of main memory. This large “fictional” memory space created by paging is called virtual memory.
操作系统内核的另一个组件是内存管理器,它负责协调机器主内存的使用。当所需的总主存空间超过计算机中实际可用的空间时,内存管理器的任务就更加复杂了。在这种情况下,内存管理器可以通过在主存和大容量存储之间来回旋转程序和数据(一种称为分页的技术)来创建额外内存空间的错觉。例如,假设需要8GB的主存,但计算机只有4GB。为了创建更大内存空间的假象,内存管理器在磁盘上保留4GB的存储空间。如果主存的实际容量为8GB,它会在那里记录将存储在主存中的位模式。这些数据被划分为大小一致的单位,称为页面,其大小通常为几KB。然后,内存管理器在主存和大容量存储之间来回切换这些页面,以便在任何给定时间需要的页面实际上都存在于4GB的主存中。其结果是,这台计算机可以像它实际上有8GB主存一样工作。由分页创建的这个巨大的“虚构”内存空间称为虚拟内存。
Two additional components within the kernel of an operating system are the scheduler and dispatcher, which we will study in the next section. For now we merely note that in a multiprogramming system the scheduler determines which activities are to be considered for execution, and the dispatcher controls the allocation of time to these activities.
操作系统内核中的另外两个组件是调度器和调度器,我们将在下一节中研究这两个组件。现在我们只注意到,在多道程序系统中,调度器决定哪些活动要考虑执行,而调度器控制这些活动的时间分配。
boot strapping (often shortened to booting )  is performed by a computer each time it is turned on.
引导捆绑(通常缩短为引导)是由计算机每次打开时执行的。

To resolve this dilemma, a small portion of a computer’s main memory where the CPU expects to find its initial program is constructed from special nonvolatile memory cells. Such memory is known as read-only memory (ROM) because its contents can be read but not altered.
为了解决这个难题,计算机主存的一小部分由特殊的非易失性存储单元构造而成,中央处理器希望在这里找到它的初始程序。这种存储器被称为只读存储器(ROM),因为它的内容可以读取,但不能更改。
In a general-purpose computer, a program called the boot loader is permanently stored in the machine’s ROM.
在通用计算机中,一个称为引导加载程序的程序永久地存储在计算机的ROM中。
The overall process of executing the boot loader and thus starting the operating system is called booting the computer.
执行引导加载程序从而启动操作系统的整个过程称为启动计算机。
The activity of executing a program under the control of the operating system is known as a process. Associated with a process is the current status of the activity, called the process
state.

在操作系统的控制下执行程序的活动称为过程。与流程相关联的是活动的当前状态,称为流程

状态。

To keep track of all the processes, the scheduler maintains a block of information in main memory called the process table.
为了跟踪所有进程,调度器在主内存中维护一个称为进程表的信息块。
Scheduler :1.Allows multiple processes to be loaded into executable memory at a time and the loaded process shares CPU (time sharing). 2.Maintains a record of processes present. 3.Adds new processes to the process table and removes completed processes from the process table.调度程序:1。允许多个进程一次加载到可执行内存中,加载的进程共享CPU(时间共享)。2. 维护当前进程的记录。3.向进程表中添加新进程,并从进程表中删除已完成的进程。
Dispatcher :1.Oversees the execution of scheduled processes.2.Controls the allocation of time slices to the processes in the process table. 3.The end of a time slice is signaled by an interrupt.
调度员:1。监督计划流程的执行。控制将时间片分配给进程表中的进程。3.一个时间片的结束以一个中断作为信号。
Each process occupies CPU for a short period of time ( a few tens of ms) .Time period is called time slice.Multiprogramming between process A and B.Process switch (or context switch).Changing one process to another
每个进程占用一小段时间(几十毫秒),这段时间称为时间片。进程A和进程b之间的多程序设计。进程切换(或上下文切换)。将一个进程更改为另一个进程
The solution to this problem is to insist that the task of testing and possibly setting the flag be completed without interruption. One approach is to use the interrupt disable and interrupt enable instructions provided in most machine languages. When executed, an interrupt disable instruction causes future interrupts to be blocked, whereas an interrupt enable instruction causes the CPU to resume responding to interrupt signals. Thus, if the operating system starts the flag-testing routine with a disable interrupt instruction and ends it with an enable interrupt instruction, no other activity can interrupt the routine once it starts.Another approach is to use the test-and-set instruction that is available inmany machine languages. This instruction directs the CPU to retrieve the value of a flag, note the value received, and then set the flag—all within a single machine instruction. The advantage here is that because the CPU always completes an instruction before recognizing an interrupt, the task of testing and setting the flag cannot be split when it is implemented as a single instruction.
这个问题的解决方案是坚持测试和可能设置标志的任务必须不中断地完成。一种方法是使用大多数机器语言中提供的中断禁用和中断启用指令。当中断执行时,interrupt disable指令会导致以后的中断被阻塞,而interrupt enable指令会导致CPU恢复响应中断信号。因此,如果操作系统用一个禁用的中断指令启动标志测试例程,并以一个启用的中断指令结束它,那么一旦例程启动,其他任何活动都不能中断它。另一种方法是使用在许多机器语言中可用的测试和设置指令。这条指令指示CPU检索一个标志的值,记录接收到的值,然后设置该标志——所有这些都在一条机器指令中。这样做的好处是,因为CPU总是在识别到一个中断之前完成一条指令,所以测试和设置标志的任务不能被拆分,当它被实现为一个单独的指令时。
A properly implemented flag, as just described, is called a semaphore, in reference to the railroad signals used to control access to sections of track.
正如前面所描述的,一个被正确实现的标志被称为信号灯,它指的是用来控制进入轨道部分的铁路信号。
Corresponding to the section of track that can contain only one train at a time is a sequence of instructions that should be executed by only one process at a time. Such a sequence of instructions is called a critical region.
与在同一时间只能包含一列火车的轨道部分相对应的是一个指令序列,在同一时间只能由一个进程执行。这样的指令序列称为临界区。
The requirement that only one process at a time be allowed to execute a critical region is known as mutual exclusion.
一次只允许一个进程执行临界区域的要求称为互斥。
Another problem that can arise during resource allocation is deadlock, the condition in which two or more processes are blocked from progressing because each is waiting for a resource that is allocated to another.
在资源分配期间可能出现的另一个问题是死锁,即两个或多个进程因等待分配给另一个进程的资源而被阻塞。

This technique of holding data for output at a later but more convenient time is called spooling.
这种保存数据以便在以后更方便的时候输出的技术称为假脱机。

chapter4

chapter5

Algorithmic operations
Ordered (first instruction, second instruction, etc.)
Able to alter the order of its instructions. ( control structure)

Three Categories of Algorithmic Operations:
Sequential operations: instructions are executed in order
顺序操作:指令按顺序执行
Conditional operations: asks true/false question and then selects the next instruction based on the answer
条件操作:询问正误问题,然后根据答案选择下一条指令
Iterative operations (loops): repeats the execution of a block of instructions
迭代操作(循环):重复执行一个指令块

Pseudo-Code (or Program Design Language)

Informal way to express the design of a computer program or an algorithm
1.Consists of natural language-like statements that precisely describe the steps of an algorithm or program
由类似于自然语言的语句组成,这些语句精确地描述了算法或程序的步骤
2. Statements describe actions
语句描述操作
3.  Focuses on the logic of the algorithm or program
重点讨论算法或程序的逻辑
4.  Avoids language-specific elements
避免特定于语言的元素
5.  Written at a level so that the desired programming code can be generated almost automatically from each statement (i.e., easy to translate statement programming code )
编写在一个级别上,以便可以从每个语句自动生成所需的编程代码(例如,易于翻译的语句→编程代码)
6.  Steps are numbered. Subordinate numbers and/or indentation are used for dependent statements in selection and repetition structures
步骤已经屈指可数了。在选择和重复结构中,从属数和/或缩进用于从属语句
example:

 

 

Binary Search Algorithm

way to use fuction

 Algorithm Efficiency

Big theta notation: Used to represent efficiency classes
Example: Sequential search is in Θ (n)
                Insertion sort is in Θ (n 2 )
                Binary search is in Θ (log 2 n)
Best, worst, and average case analysis
Insertion sort in a worst-case situation

Proof of correctness

Assertions: true-false statement placed in a program to assert that it is true at that point
在一个程序中,错误的语句断言它在这一点上是正确的
Preconditions: assertion placed before a statement.True before the execution of the algorithm
在语句前放置的断言。在算法执行之前
Postconditions : assertion placed after a statement .True after the execution of the algorithm
在语句后放置的断言。在算法执行之后
Loop invariant : assertion supposed to be true before and after each iteration of the loop
在循环的每次迭代前后都应该是正确的
An assertion must specify the desired output of the algorithm.
断言必须指定算法的预期输出。
If , given the preconditions, each identified assertion is true when the execution reaches that particular point, then the algorithm is correct
如果考虑到先决条件,当执行到达该特定的点时,每个确定的断言是正确的,那么算法是正确的

chapter6

chapter7

chapter8

Basic Data Structures

Array: A block of data whose entries are of same type
A two dimensional array consists for rows and columns
Indices are used to identify positions
A two-dimensional array with two rows and nine columns
Aggregate : A block of data items that might be of different type or sizes
Each data item is called a field
Fields are usually accessed by name
List : A collection of data whose entries are arranged sequentially
Head : The beginning of the list
Tail : The end of the list
Tree: A collection of data whose entries have a hierarchical organization
Node: An entry in a tree
Root node: The node at the top
Terminal (or leaf ) node: A node at the bottom
Parent : The node immediately above a specified node
Child : A node immediately below a specified node
Ancestor : Parent, parent of parent, etc.
Descendent : Child, child of child, etc.
Siblings: Nodes sharing a common parent

 data structures

Stack : A list in which entries are removed and inserted only at the
head

LIFO : Last-in-first-out
Top : The head of list (stack)
Bottom or base: The tail of list (stack)
Pop : To remove the entry at the top
Push : To insert an entry at the top
Queue : A list in which entries are removed at the head and are inserted at the tail

FIFO : First-in-first-out

Related Concepts

Abstraction
Shield users (application software) from details of actual data storage
从实际数据存储的细节中,保护用户(应用软件)
Static vs. Dynamic Structure
Does the shape and size change over time?
随着时间的推移,形状和大小会改变吗?
Pointer
A storage area that encodes an address where data is stored
一个存储区域,它编码一个数据存储的地址
Later used to access the data
后来使用的用于访问数据

Storing Arrays

 

 

 

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

岩塘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值