How to Build an 8-Bit Computer : 18 Steps (with Pictures) - Instructables
https://www.instructables.com/id/How-to-Build-an-8-Bit-Computer/
中断方式与轮询方式
标签(空格分隔): 计算机
原文链接:http://lionwq.spaces.eepw.com.cn/articles/article/item/18936#
1. 中断方式的基本概念
程序中断通常简称中断,是指CPU在正常运行程序的过程中,由于预选安排或发生了各种随机的内部或外部事件,使CPU中断正在运行的程序,而转到为相应的服务程序去处理,这个过程称为程序中断。
2. 80 x86微处理器的中断
80 x86微处理器的中断类型一般分为2类,即由于执行某些指令引起的软中断和由处理器以外其他控制电路发出中断请求信号引起的硬中断。 CPU要从主程序转入中断服务程序,必须知道该中断服务程序的入口地址,即中断向量。80 x86为CPU的PC机共有256个中断向量。
中断的一般过程:
主程序只是在设备A,B,C数据准备就绪时,才去处理A,B,C,进行数据交换。在速度较慢的外围设备准备自己的数据时,CPU照常执行自己的主程序 。在这个意义上说,CPU和外围设备的一些操作是并行地进行的,因而同串行进行的程序查询方式相比,计算机系统的效率是大大提高了。如下图:
Start-->|主程序| node1
node1 --> node2
node2 --> node3
node3 --> End
A[鼠标]-->|请求中断| node1
node1 --> |响应中断| A
B[键盘]-->|请求中断| node2
node2 --> |响应中断| B
C[摄像头]-->|请求中断| node3
node3 --> |响应中断| C
实际的中断过程还要复杂一些,下图示出了中断处理过程的详细流程图.当CPU执行完—条现行指令时,如果外设向CPU发出中断请求
,那么CPU在满足响应条件的情况下,将发出中断响应
信号,与此同时关闭中断
(中断屏蔽
触发器置1
),表示CPU不再受理另外—个设备的中断。这时、CPU将寻找中断请求源
是哪个设备。并保存CPU自己的程序计数器(PC)的内容
.然后,它将转移到处理该中断源的中断服务程序
.CPU再保存现场信息
,执行设备服务(如交换数据)以后.将恢复现场信息
。在这些动作完成以后,开放中断
(中断屏蔽
触发器置0
),并返回到原来被中断的主程序的下一条指令。
start=>start
op1=>operation: 取指令
op2=>operation: 执行指令
op3=>operation: 响应中断
op4=>operation: 转移到中断服务子程序
op5=>operation: 关闭中断,中断屏蔽复位
op6=>operation: 找出中断源,保存计数器(PC)
op7=>operation: 保存CPU现场
op8=>operation: 执行设备服务
op9=>operation: 恢复CPU现场
op10=>operation: 打开中断,返回主程序执行下一条命令
cond1=>condition: 中断
sub1=>subroutine: 中断服务程序(比如键盘输入响应程序)
start->op1->op2->cond1
cond1(no)->op1
cond1(yes)->op3->op4->sub1->op9->op10->op1
- 尽管外界中断请求是随机的,但CPU只有在当前一条指令执行完毕后,即转入公操作[^note1]时才受理设备的中断请求,这样才不致于使当前指令的执行受到干扰。公操作是指一条指令执行结束后CPU所进行的操作,如中断处理、直接内存传送、取下条指令等。外界中断请求信号通常存放在接口中的
中断源锁存器
里,并通过中断请求线连至CPU,每当一条指令执行到末尾,CPU便检查中断请求信号。若中断请求信号为1
,则CPU转入中断周期
,受理外界中断。 - 为了在中断服务程序执行完毕以后正确地返回到原来主程序被中断的断点(PC内容)而继续执行主程序,必须把程序计数器PC的内容,以及当前指令执行结束后CPU的状态(包括寄存器的内容和一些状态标志位)都保存到堆栈中去。这些操作叫做保存现场。
- 当CPU响应中断后,正要去执行中断服务程序时,可能有另一个新的中断源向它发出中断请求。为了不致造成混乱,在CPU的中断管理部件中必须有一个
中断屏蔽触发器
,它可以在程序的控制下置1
(设置屏蔽),或置0
(取掉屏蔽)。只有在中断屏蔽标志为0
时,CPU才可以受理中断。当一条指令执行完毕,CPU接受中断请求并作出响应时,它一方面发出中断响应信号INTA
,另一方面把中断屏蔽标志置1
,即关闭中断。这样,CPU不能再受理另外的新的中断源发来的中断请求。只有在CPU把中断服务程序执行完毕以后,它才重新使中断屏蔽标志置0
,即开放中断,并返回主程序。因此,中断服务程序的最后必须有两条指令
,即开中断指令
和返主指令
,同时在硬件上要保证返主指令执行以后才受理新的中断请求。 - 中断处理过程是由
硬件
和软件
结合来完成的。如在前图中,中断周期由硬件实现,而中断服务程序由机器指令序列
实现。后者除执行保存现场
、恢复现场
、开放中断并返回主程序
任务外,对要求中断的设备进行服务,使其同CPU交换一定的数据,或作其他服务。
3. 轮询方式的基本概念
轮询(Polling)I/O方式
,也称作程序控制I/O方式
,是让CPU以一定的周期按次序查询每一个外设,看它是否有数据输入或输出的要求,若有,则进行相应的输入/输出
服务;若无,或I/O处理完毕后,CPU就接着查询下一个外设。
- 所需硬件:外设接口提供状态端口、数据端口
- 软件机制:应用程序必须定时查询各个接口的状态端口,判断是否需要输入、输出数据,如果需要,则通过数据端口进行数据操作。
- 特点:CPU通过执行指令主动对外部设备进行查询,外部设备处于被动地位 。
st=>start: 开始 end=>end: 结束 cond1=>condition: 设备需要数据交换 sub1=>subroutine: 执行一段应用程序 cond2=>condition: 是否结束 op1=>operation: 通过端口执行数据交换
st->cond1
cond1(no)->sub1->cond2
cond1(yes)->op1->sub1
cond2(yes)->end
cond2(no)->cond1
<center>上图为一般过程。</center>
## 4. 轮询方式与中断方式的比较
### 速度
#### 程序控制方式
**硬件的速度指标**:由于`程序控制方式`完全采用软件的方式对外设接口进行控制,所以它的硬件操作只是普通的端口读写,并无特别之处,其速度指标由`总线传输速度`、`端口的响应速度`共同决定。
对于这种外设控制方式,速度指标关键在于**软件**。
#### 中断处理方式
中断处理方式本身所作的原子操作解释和程序控制方式是一致的。
只不过因为加入了中断请求和响应机制,对状态端口的读取变成了在中断响应过程中对中断号的读取,对状态端口的判断变成了对中断入口地址的确定。
从本质上来说,中断处理方式和程序控制方式本身的速度指标一致,没有大的差别。
### 可靠性
#### 程序控制方式
由于硬件不支持中断方式,因此操作系统把CPU控制权交给应用程序后,只要应用程序不交还CPU控制权,操作系统就始终不能恢复对CPU的控制(无定时中断)。应用程序与操作系统都是软件模块,操作系统属于核心模块,它们之间存在交接CPU控制权的关系。正是由于这样的关系,一旦使用对外设的`程序控制方式`时,应用程序出现死锁,则操作系统永远无法恢复对系统的控制。应用程序的故障通过外设控制方式波及到作为核心模块的操作系统,因此,根据关联可靠性指标的计算可知,`程序控制方式`的关联可靠性指标很低。
#### 中断处理方式
由于提供定时中断,操作系统可以在应用程序当前时间片结束后通过中断服务程序重新获得对CPU的控制权。应用程序的故障不会波及到操作系统,因此,中断处理方式的关联可靠性指标高。
###可扩展性
#### 程序控制方式
由于所有应用程序中都包含对端口的操作,一旦硬件接口的设计发生变化,则所有应用程序都必须进行修改,这会使修改费用升高很多倍。因此,程序控制方式会使相关硬件模块的局部修改指标相对较低。
#### 中断处理方式
应用程序不直接操作端口,对端口的操作是由中断服务程序来完成的。如果某个硬件接口的设计发生了变化,只需要修改它相关的中断服务程序即可。因此,中断处理方式使得相关硬件模块的局部修改指标较高。
### 生命期
#### 程序控制方式(CPU查询方式)
在早期的计算机系统中能够满足应用需求;但是随着外部设备种类的增多、速度差异的加大,这种方式逐渐成为系统性能提高的障碍。它的生命期只限于早期计算机阶段,因为当时外部设备少,且都是低速设备,到8位机出现以后,这种外设控制方式(体系结构)被淘汰。
####中断处理方式(外设请求方式)
能够协调CPU与外设间的速度差异,能够协调各种外设间的速度差异,提高系统的工作效率(速度指标)。使应用程序与外设操作基本脱离开来,降低了程序的设备相关性(关联可靠性指标、局部修改指标)。虽然目前某些快速设备相互间的通信没有通过CPU,也没有使用中断处理方式,但是对于慢速设备、设备故障的处理来说,中断处理方式仍然是最有效的。无论将来计算机系统中的元件怎样变化,只要存在慢速设备与快速CPU之间的矛盾,使用中断处理方式都是适合的。即便不使用中断服务程序,中断的概念也会保持很久。在短时期内,计算机系统还无法在所有领域离开人工交互操作,人的操作速度一定比机器的处理速度慢,因此慢速设备将仍然保持存在(但这不是慢速设备存在的唯一原因)。正因为存在这样的需求,中断处理方式具有较长的生命期。
[^note1]:**公操作**:所谓公操作,就是一条指令执行完毕后,CPU所开始进行的一些操作,这些操作主要是CPU对外围设备请求的处理,如中断处理、通道处理等。如果外围设备没有向CPU请求交换数据,那么CPU又转向下一条指令。由于所有指令的取指周期是完全一样的,因此,取指令也可以认为是`公操作`。这是因为,一条指令执行结束后,如果没有外设请求,CPU一定转 入“取指令”操作。
### 究竟什么是冯诺依曼瓶颈(von Neumann Bottleneck)?
> https://blog.csdn.net/guojunxiu/article/details/79942905
先看一下冯诺依曼结构:
![img](02.assets/20180414182557311.png)
再看一下冯诺依曼结构的“对头”——哈佛结构:
![img](02.assets/20180418225620918.png)
可以看到两者的主要差别是冯诺依曼架构不区分数据与指令,将两者放在同一内存中;而哈佛结构将两者分别存放在Instruction Memory和Data Memory。
指令和数据放在一起的后果是取指令和取数据不能同时进行,否则会引起访存的混乱。发展到今天,CPU的运算速度已经远远超过了访存速度,因此CPU必须浪费时间等数据;而哈佛构架由于指令和数据是分开存放的,所以在等数据的同时可以预取指令,CPU的利用率更高。
由于指令与数据放在同一内存带来的CPU利用率(吞吐率)降低就是冯诺依曼瓶颈
维基百科的解释如下:
> The shared bus between the program memory and data memory leads to the von Neumann bottleneck, the limited throughput (data transfer rate) between the central processing unit (CPU) and memory compared to the amount of memory. Because the single bus can only access one of the two classes of memory at a time, throughput is lower than the rate at which the CPU can work. This seriously limits the effective processing speed when the CPU is required to perform minimal processing on large amounts of data. The CPU is continually forced to wait for needed data to be transferred to or from memory. Since CPU speed and memory size have increased much faster than the throughput between them, the bottleneck has become more of a problem, a problem whose severity increases with every newer generation of CPU.
冯诺依曼瓶颈的缓解办法有:
1. Providing a cache between the CPU and the main memory
2. providing separate caches or separate access paths for data and instructions (the so-called Modified Harvard architecture)
3. using branch predictor algorithms and logic
4. providing a limited CPU stack or other on-chip scratchpad memory to reduce memory access
实际上,绝大多数现代计算机使用的是所谓的“Modified Harvard Architecture”,指令和数据共享同一个 address space,但缓存是分开的。在内存里,指令和数据是在一起的。而在CPU内的缓存中,还是会区分指令缓存和数据缓存,最终执行的时候,指令和数据是从两个不同的地方出来的。你可以理解为在CPU外部,采用的是冯诺依曼模型,而在CPU内部用的是哈佛结构。
参考:
[冯诺依曼架构](https://zh.wikipedia.org/wiki/%E5%86%AF%C2%B7%E8%AF%BA%E4%BC%8A%E6%9B%BC%E7%BB%93%E6%9E%84)
[哈佛架构](https://zh.wikipedia.org/wiki/%E5%93%88%E4%BD%9B%E7%BB%93%E6%9E%84)
[知乎:为什么电脑还沿用冯·诺伊曼结构而不使用哈佛结构? ](https://www.zhihu.com/question/22406681)
# 性能之殇 - 天才冯·诺依曼与冯·诺依曼瓶颈
> 性能之殇(一)-- 天才冯·诺依曼与冯·诺依曼瓶颈 - 岁寒
> https://lvwenhan.com/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/492.html
电子计算机与信息技术是最近几十年人类科技发展最快的领域,无可争议地改变了每个人的生活:从生活方式到战争方式,从烹饪方式到国家治理方式,都被计算机和信息技术彻底地改变了。如果说核武器彻底改变了国与国之间相处的模式,那么计算机与信息技术则彻底改变了人类这个物种本身,人类的进化也进入了一个新的阶段。
> 简单地说,生物进化之前还有化学进化。 然而细胞一经诞生,中心法则的分子进化就趋于停滞了:38亿年来,中心法则再没有新的变动,所有的蛋白质都由 20 种标准氨基酸连成,连碱基与氨基酸对应关系也沿袭至今,所有现代生物共用一套标准遗传密码。 正如中心法则是化学进化的产物,却因为开创了生物进化而停止了化学进化,人类是生物进化的产物,也因为开创了文化进化和技术进化而停止了生物进化——进化已经走上了更高的维度。
>
> -- [《进化的阶次 | 混乱博物馆》](https://zhuanlan.zhihu.com/p/44211397)
## 本文目标
上面的只是我的喃喃私语,下面我们进入正题。
本文的目标是在我有限的认知范围内,讨论一下人们为了提高性能做出的种种努力,这里面包含硬件层面的 CPU、RAM、磁盘,操作系统层面的并发、并行、事件驱动,软件层面的多进程、多线程,网络层面的分布式,等等等等。事实上,上述名词并不局限于某一个层面,计算机从 CPU 内的门电路到显示器上浏览器中的某行字,是层层协作才得以实现的;计算机科学中的许多概念,都跨越了层级:事件驱动就是 CPU 和操作系统协作完成的。
### 可能的文章列表
以下是可能的文章列表,我在撰写过程中可能会随时修改:
1. 天才冯·诺依曼与冯·诺伊曼瓶颈
2. 分支预测、流水线与多核 CPU
3. 通用电子计算机的胎记:事件驱动
4. Unix 进程模型的局限
5. DPDK、SDN 与大页内存
6. 现代计算机最亲密的伙伴:局部性与乐观
7. 分布式计算、超级计算机与神经网络共同的瓶颈
## 天才 冯·诺依曼
冯·诺依曼1903年12月28日出生于奥匈帝国布达佩斯,1957年2月8日卒于美国,终年53岁。在他短暂的一生中,他取得了巨大的成就,远不止于世人熟知的“冯·诺依曼架构”。
> 约翰·冯·诺伊曼,出生于匈牙利的美国籍犹太人数学家,现代电子计算机与博弈论的重要创始人,在泛函分析、遍历理论、几何学、拓扑学和数值分析等众多数学领域及计算机学、量子力学和经济学中都有重大贡献。
>
> -- [约翰·冯·诺伊曼的维基百科](https://zh.wikipedia.org/wiki/约翰·冯·诺伊曼)
除了对计算机科学的贡献,他还有一个称号不被大众所熟知:“博弈论之父”。博弈论被认为是20世纪经济学最伟大的成果之一。(说到博弈论,我相信大多数人第一个想到的肯定跟我一样,那就是“纳什均衡”)
## 冯·诺依曼架构
冯·诺依曼由于在曼哈顿工程中需要大量的运算,从而使用了当时最先进的两台计算机 Mark I 和 ENIAC,在使用 Mark I 和 ENIAC 的过程中,他意识到了存储程序的重要性,从而提出了存储程序逻辑架构。
“冯·诺依曼架构”定义如下:
1. 以运算单元为中心
2. 采用存储程序原理
3. 存储器是按地址访问、线性编址的空间
4. 控制流由指令流产生
5. 指令由操作码和地址码组成
6. 数据以二进制编码
### 优势
冯·诺依曼架构第一次将存储器和运算器分开,指令和数据均放置于存储器中,为计算机的通用性奠定了基础。虽然在规范中计算单元依然是核心,但冯·诺依曼架构事实上导致了以存储器为核心的现代计算机的诞生。
##### 注:请各位在心里明确一件事情:存储器指的是内存,即 RAM。磁盘理论上属于输入输出设备。
该架构的另一项重要贡献是用二进制取代十进制,大幅降低了运算电路的复杂度。这为晶体管时代超大规模集成电路的诞生提供了最重要的基础,让我们实现了今天手腕上的 Apple Watch 运算性能远超早期大型计算机的壮举,这也是摩尔定律得以实现的基础。
### 冯·诺伊曼瓶颈
冯·诺依曼架构为计算机大提速铺平了道路,却也埋下了一个隐患:在内存容量指数级提升以后,CPU 和内存之间的数据传输带宽成为了瓶颈。
![img](03.assets/2018-11-12-15418429805287.jpg)
上图是 i9-7980XE 18 核 36 线程的民用最强 CPU,其配合超频过的 DDR4 3200MHz 的内存,测试出的内存读取速度为 90GB/S。看起来很快了是不是?看看图中的 L1 Cache,3.7TB/S。
我们再来算算时间。这颗 CPU 最大睿频 4.4GHz,就是说 CPU 执行一个指令需要的时间是 0.000000000227273 秒,即 0.22ns(纳秒),而内存的延迟是 68.1ns。换句话说,只要去内存里取一个字节,就需要 CPU 等待 300 个周期,何其的浪费 CPU 的时间啊。
CPU L1 L2 L3 三级缓存是使用和 CPU 同样的 14 纳米工艺制造的硅半导体,每一个 bit 都使用六个场效应管(通俗解释成三极管)构成,成本高昂且非常占用 CPU 核心面积,故不能做成很大容量。
除此之外,L1 L2 L3 三级缓存对计算机速度的提升来源于计算机内存的“局部性”,相关内容我们之后会专门讨论。
### 接下来
下一篇文章,我们将讨论分支预测、流水线与多核 CPU,看看那些上古大神们为了提升性能都迸发出了什么奇思妙想,搞出了什么奇技淫巧。
CPU 硬件为了提高性能,逐步发展出了指令流水线(分支预测)和多核 CPU,本文我们就将简单地探讨一下它们的原理和效果。
## 指令流水线
在一台纯粹的图灵机中,指令是一个一个顺序执行的。而现实世界的通用计算机所用的很多基础算法都是可以并行的,例如加法器和乘法器,它们可以很容易地被切分成可以同时运行的多个指令,这样就可以大幅提升性能。
#### 指令流水线,说白了就是 CPU 电路层面的并发。
> Intel Core i7 自 Sandy Bridge(2010)架构以来一直都是 14 级流水线设计。基于 Cedar Mill 架构的最后一代奔腾4,在 2006 年就拥有 3.8GHz 的超高频率,却因为其长达 31 级的流水线而成了为样子货,被 AMD 1GHz 的芯片按在地上摩擦。
### RISC机器的五层流水线示意图
下图形象的展示了流水线式如何提高性能的。
![img](03.assets/2018-11-13-15420388503692.jpg)
### 缺点
指令流水线通过硬件层面的并发来提高性能,却也带来了一些无法避免的缺点。
1. 设计难度高,一不小心就成为了高频低能的奔四
2. 并发导致每一条指令的执行时间变长
3. 优化难度大,有时候两行代码的顺序变动就可能导致数倍的性能差异,这对编译器提出了更高的要求
4. 如果多次分支预测失败,会导致严重的性能损失
## 分支预测
指令形成流水线以后,就需要一种高效的调控来保证硬件层面并发的效果:最佳情况是每条流水线里的十几个指令都是正确的,这样完全不浪费时钟周期。而分支预测就是干这个的:
分支预测器猜测条件表达式两路分支中哪一路最可能发生,然后推测执行这一路的指令,来避免流水线停顿造成的时间浪费。但是,如果后来发现分支预测错误,那么流水线中推测执行的那些中间结果全部放弃,重新获取正确的分支路线上的指令开始执行,这就带来了十几个时钟周期的延迟,这个时候,这个 CPU 核心就是完全在浪费时间。
#### 幸运的是,当下的主流 CPU 在现代编译器的配合下,把这项工作做得越来越好了。
> 还记得那个让 Intel CPU 性能跌 30% 的漏洞补丁吗,那个漏洞就是 CPU 设计的时候,分支预测设计的不完善导致的。
## 多核 CPU
多核 CPU 的每一个核心拥有自己独立的运算单元、寄存器、一级缓存、二级缓存,所有核心共用同一条内存总线,同一段内存。
多核 CPU 的出现,标志着人类的集成电路工艺遇到了一个严酷的瓶颈,没法再大规模提升单核性能,只能使用多个核心来聊以自慰。实际上,多核 CPU 性能的提升极其有限,远不如增加一点点单核频率提升的性能多。
### 优势
多核 CPU 的优势很明显,就是可以并行地执行多个图灵机,可以显而易见地提升性能。只不过由于使用同一条内存总线,实际带来的效果有限,并且需要操作系统和编译器的密切配合才行。
> 题外话: AMD64 技术可以运行 32 位的操作系统和应用程序,所用的方法是依旧使用 32 位宽的内存总线,每计算一次要取两次内存,性能提升也非常有限,不过好处就是可以使用大于 4GB 的内存了。大家应该都没忘记第一篇文章中提到的冯·诺依曼架构拥有 CPU 和内存通信带宽不足的弱点。(注:AMD64 技术是和 Intel 交叉授权的专利,i7 也是这么设计的)
### 劣势
多核 CPU 劣势其实更加明显,但是人类也没有办法,谁不想用 20GHz 的 CPU 呢,谁想用这八核的 i7 呀。
1. 内存读写效率不变,甚至有降低的风险
2. 操作系统复杂度提升很多倍,计算资源的管理复杂了太多了
3. 依赖操作系统的进步:微软以肉眼可见的速度,在这十几年间大幅提升了 Windows 的多核效率和安全性:XP 只是能利用,7 可以自动调配一个进程在多个核心上游走,2008R2 解决了依赖 CPU0 调度导致死机的 bug(中国的银行提的 bug 哦),8 可以利用多核心启动,10 优化了杀进程依赖 CPU0 的问题。
> #### 超线程技术
>
> Intel 的超线程技术是将 CPU 核心内部再分出两个逻辑核心,只增加了 5% 的裸面积,就带来了 15%~30% 的性能提升。
## 怀念过去
Intel 肯定怀念摩尔定律提出时候的黄金年代,只依靠工艺的进步,就能一两年就性能翻番。AMD 肯定怀念 K8 的黄金一代,1G 战 4G,靠的就是把内存控制器从北桥芯片移到 CPU 内部,提升了 CPU 和内存的通信效率,自然性能倍增。而今天,人类的技术已经到达了一个瓶颈,只能通过不断的提升 CPU 和操作系统的复杂度来获得微弱的性能提升,呜呼哀哉。
不过我们也不能放弃希望,AMD RX VAGA64 显卡拥有 2048 位的显存位宽,理论极限还是很恐怖的,这可能就是未来内存的发展方向。
Event-Driven(事件驱动)这个词这几年随着 Node.js® 的大热也成了一个热词,似乎已经成了“高性能”的代名词,殊不知事件驱动其实是通用计算机的胎记,是一种与生俱来的能力。本文我们就要一起了解一下事件驱动的价值和本质。
## 通用电子计算机中的事件驱动
首先我们定义当下最火的 x86 PC 机为典型的通用电子计算机:可以写文章,可以打游戏,可以上网聊天,可以读U盘,可以打印,可以设计三维模型,可以编辑渲染视频,可以作路由器,还可以控制巨大的工业机器。那么,这种计算机的事件驱动能力就很容易理解了:
1. 假设 Chrome 正在播放 Youtube 视频,你按下了键盘上的空格键,视频暂停了。这个操作就是事件驱动:计算机获得了你单击空格的事件,于是把视频暂停了。
2. 假设你正在跟人聊 QQ,别人发了一段话给你,计算机获得了网络传输的事件,于是将信息提取出来显示到了屏幕上,这也是事件驱动。
## 事件驱动的实现方式
事件驱动本质是由 CPU 提供的,因为 CPU 作为 控制器 + 运算器,他需要随时响应意外事件,例如上面例子中的键盘和网络。
CPU 对于意外事件的响应是依靠 Exception Control Flow(异常控制流)来实现的。
## 强大的异常控制流
异常控制流是 CPU 的核心功能,它是以下听起来就很牛批的功能的基础:
### 时间片
CPU 时间片的分配也是利用异常控制流来实现的,它让多个进程在宏观上在同一个 CPU 核心上同时运行,而我们都知道在微观上在任一个时刻,每一个 CPU 核心都只能运行一条指令。
### 虚拟内存
> 这里的虚拟内存不是 Windows 虚拟内存,是 Linux 虚拟内存,即逻辑内存。
逻辑内存是用一段内存和一段磁盘上的存储空间放在一起组成一个逻辑内存空间,对外依然表现为“线性数组内存空间”。逻辑内存引出了现代计算机的一个重要的性能观念:
#### 内存局部性天然的让相邻指令需要读写的内存空间也相邻,于是可以把一个进程的内存放到磁盘上,再把一小部分的“热数据”放到内存中,让其作为磁盘的缓存,这样可以在降低很少性能的情况下,大幅提升计算机能同时运行的进程的数量,大幅提升性能。
虚拟内存的本质其实是使用 缓存 + 乐观 的手段提升计算机的性能。
### 系统调用
系统调用是进程向操作系统索取资源的通道,这也是利用异常控制流实现的。
### 硬件中断
键盘点击、鼠标移动、网络接收到数据、麦克风有声音输入、插入 U 盘这些操作全部需要 CPU 暂时停下手头的工作,来做出响应。
### 进程、线程
进程的创建、管理和销毁全部都是基于异常控制流实现的,其生命周期的钩子函数也是操作系统依赖异常控制流实现的。线程在 Linux 上和进程几乎没有功能上的区别。
### 编程语言中的 try catch
C++ 编译成的二进制程序,其异常控制语句是直接基于异常控制流的。Java 这种硬虚拟机语言,PHP 这种软虚拟机语言,其异常控制流的一部分也是有最底层的异常控制流提供的,另一部分可以由逻辑判断来实现。
## 基于异常控制流的事件驱动
其实现在人们在谈论的事件驱动,是 Linux kernel 提供的 epoll,是 2002 年 10 月 18 号伴随着 kernel 2.5.44 发布的,是 Linux 首次将操作系统中的 I/O 事件的异常控制流暴露给了进程,实现了本文开头提到的 Event-Driven(事件驱动)。
### Kqueue
FreeBSD 4.1 版本于 2000 年发布,起携带的 Kqueue 是 BSD 系统中事件驱动的 API 提供者。BSD 系统如今已经遍地开花,从 macOS 到 iOS,从 watchOS 到 PS4 游戏机,都受到了 Kqueue 的蒙荫。
### epoll 是什么
操作系统本身就是事件驱动的,所以 epoll 并不是什么新发明,而只是把本来不给用户空间用的 api 暴露在了用户空间而已。
### epoll 做了什么
网络 IO 是一种纯异步的 IO 模型,所以 Nginx 和 Node.js® 都基于 epoll 实现了完全的事件驱动,获得了相比于 select/poll 巨量的性能提升。而磁盘 IO 就没有这么幸运了,因为磁盘本身也是单体阻塞资源:即有进程在写磁盘的时候,其他写入请求只能等待,就是天王老子来了也不行,磁盘做不到呀。所以磁盘 IO 是基于 epoll 实现的非阻塞 IO,但是其底层依旧是异步阻塞,即便这样,性能也已经爆棚了。Node.js 的磁盘 IO 性能远超其他解释型语言,过去几年在 web 后端霸占了一些对磁盘 IO 要求高的领域。
Unix 系统 1969 年诞生于 AT&T 旗下的贝尔实验室。1971 年,Ken Thompson(Unix之父) 和 Dennis Ritchie(C语言之父)共同发明了 C 语言,并在 1973 年用 C 语言重写了 Unix。
Unix 自诞生起就是多用户、多任务的分时操作系统,其引入的“进程”概念是计算机科学中最成功的概念之一,几乎所有现代操作系统都是这一概念的受益者。但是进程也有局限,由于 AT&T 是做电话交换起家,所以 Unix 进程在设计之初就是延续的电话交换这个业务需求:保证电话交换的效率,就够了。
1984年,Richard Stallman 发起了 GNU 项目,目标是创建一个完全自由且向下兼容 Unix 的操作系统。之后 Linus Torvalds 与 1991 年发布了 Linux 内核,和 GNU 结合在了一起形成了 GNU/Linux 这个当下最成功的开源操作系统。所以 Redhat、CentOS、Ubuntu 这些如雷贯耳的 Linux 服务器操作系统,他们的内存模型也是高度类似 Unix 的。
## Unix 进程模型介绍
进程是操作系统提供的一种抽象,每个进程在自己看来都是一个独立的图灵机:独占 CPU 核心,一个一个地运行指令,读写内存。进程是计算机科学中最重要的概念之一,是进程使多用户、多任务成为了可能。
### 上下文切换
操作系统使用上下文切换让一个 CPU 核心上可以同时运行多个进程:在宏观时间尺度,例如 5 秒内,一台电脑的用户会认为他的桌面进程、音乐播放进程、鼠标响应进程、浏览器进程是在同时运行的。
![img](03.assets/2018-11-14-15421822806315.jpg)
- 图片来自《CS:APP》
### 上下文切换的过程
以下就是 Linux 上下文切换的过程:
假设正在运行网易云音乐进程,你突然想搜歌,假设焦点已经位于搜索框内。
1. 当前进程是网易云音乐,它正在优哉游哉的播放着音乐
2. 你突然打字,CPU 接到键盘发起的中断信号(异常控制流中的一个异常),准备调起键盘处理进程
3. 将网易云音乐进程的寄存器、栈指针、程序计数器保存到内存中
4. 将键盘处理进程的寄存器、栈指针、程序计数器从内存中读出来,写入到 CPU 内部相应的模块中
5. 执行程序计数器的指令,键盘处理程序开始处理键盘输入
6. 完成了一次上下文切换
### 名词解释
> - 寄存器:CPU 核心里的用于暂时存储指令、地址和数据的电路,和内核频率一样,速度极快
> - 栈指针:该进程所拥有的栈的指针
> - 程序计数器:简称 PC,它存储着内核将要执行的下一个指令的内存地址。程序计数器是图灵机的核心组成部分。还记得冯·诺依曼架构吗,它的一大创造就是把指令和数据都存在内存里,让计算机获得了极大的自由度。
## Unix 进程模型的局限
Unix 进程模型十分的清晰,上下文切换使用了一个非常简单的操作就实现了多个进程的宏观同时运行,是一个伟大的杰作。但是它却存在着一个潜在的缺陷,这个缺陷在 Unix 诞生数十年之后才渐渐浮出了水面。
### 致命的内存
进程切换过程中需要分别写、读一次内存,这个操作在 Unix 刚发明的时候没有发现有什么性能问题,但是 CPU 裹挟着摩尔定律一路狂奔,2000 年,AMD 领先 Intel 两天发布了第一款 1GHz 的微处理器 “AMD Athlon 1GHz”,此时一个指令的执行时间已经低到了 1ns,而其内存延迟高达 60ns,这导致了一个以前不曾出现的问题:
> 上下文切换读写内存的时间成了整个系统的性能瓶颈。
### 软件定义一切
我们将在下一篇文章探讨 SDN(软件定义网络),在这里我们先来看一下“软件定义一切”这个概念。当下,不仅有软件定义网络,还有软件定义存储,甚至出现了软件定义基础架构(这不就是云计算嘛)。是什么导致了软件越来越强势,开始倾入过去只有专业的硬件设备才能提供的高性能高稳定性服务呢?我认为,就是通用计算机的发展导致的,确切地说,是 CPU 和网络的发展导致的。
当前的民用顶级 CPU 的性能已经爆表,因为规模巨大,所以其价格也要显著低于同性能的专用处理器:自建 40G 软路由的价格大约是 40G 专用路由价格的二十分之一。
![Jietu20181114-172151](03.assets/aa.jpg)
下一篇文章我们将讨论上图中的 DPDK、SDN 以及知名的性能优化方案“大页内存”。
上文我们说到,当今的 x86 通用微处理器已经拥有了十分强大的性能,得益于其庞大的销量,让它的价格和专用 CPU 比也有着巨大的优势,于是,软件定义一切诞生了!
## 软路由
说到软路由,很多人都露出了会心的微笑,因为其拥有低廉的价格、超多的功能、够用的性能和科学上网能力。现在网上能买到的软路由,其本质就是一个 x86 PC 加上多个网口,大多是基于 Linux 或 BSD 内核,使用 Intel 低端被动散热 CPU 打造出的千兆路由器,几百块就能实现千兆的性能,最重要的是拥有 QOS、多路拨号、负载均衡、防火墙、VPN 组网、科学上网等强大功能,传统路由器抛开科学上网不谈,其他功能也不是几百块就搞得定的。
### 软路由的弱点
软路由便宜,功能强大,但是也有弱点。它最大的弱点其实是性能:传统 *UNIX 网络栈的性能实在是不高。
软路由的 NAT 延迟比硬路由明显更大,而且几百块的软路由 NAT 性能也不够,跑到千兆都难,而几百块的硬路由跑到千兆很容易。那怎么办呢?改操作系统啊。
## SDN
软件定义网络,其本质就是使用计算机科学中最常用的“虚拟机”构想,将传统由硬件实现的 交换、网关、路由、NAT 等网络流量控制流程交由软件来统一管理:可以实现硬件不动,网络结构瞬间变化,避免了传统的停机维护调试的烦恼,也为大规模公有云计算铺平了道路。
### 虚拟机
虚拟机的思想自底向上完整地贯穿了计算机的每一个部分,硬件层有三个场效应管虚拟出的 SRAM、多个内存芯片虚拟出的一个“线性数组内存”,软件层有 jvm 虚拟机,PHP 虚拟机(解释器)。自然而然的,当网络成为了更大规模计算的瓶颈的时候,人们就会想,为什么网络不能虚拟呢?
### OpenFlow
最开始,SDN 还是基于硬件来实施的。Facebook 和 Google 使用的都是 OpenFlow 协议,作用在数据链路层(使用 MAC 地址通信的那一层,也就是普通交换机工作的那一层),它可以统一管理所有网关、交换等设备,让网络架构实时地做出改变,这对这种规模的公司所拥有的巨大的数据中心非常重要。
## DPDK
DPDK 是 SDN 更前沿的方向:使用 x86 通用 CPU 实现 10Gbps 甚至 40Gbps 的超高速网关(路由器)。
### DPDK 是什么
Intel DPDK 全称为 Intel Data Plane Development Kit,直译为“英特尔数据平面开发工具集”,它可以摆脱 *UNIX 网络数据包处理机制的局限,实现超高速的网络包处理。
![Jietu20181114-172151](03.assets/aa.jpg)
### DPDK 的价值
当下,一台 40G 核心网管路由器动辄数十万,而 40G 网卡也不会超过一万块,而一颗性能足够的 Intel CPU 也只需要几万块,软路由的性价比优势是巨大的。
实际上,阿里云和腾讯云也已经基于 DPDK 研发出了自用的 SDN,已经创造了很大的经济价值。
> [【DPDK峰会回顾】支撑双十一的高性能负载均衡是如何炼成的](https://yq.aliyun.com/articles/615587) [阿里云携领先SDN能力,亮相全球网络技术盛会ONS](https://yq.aliyun.com/articles/575989) [腾讯云超高网络性能云主机揭秘](https://cloud.tencent.com/developer/article/1006690) [F-Stack 全用户态 (Kernel Bypass) 服务开发套件](https://cloud.tencent.com/developer/article/1005179)
## 怎么做到的?
DPDK 使用自研的数据链路层(MAC地址)和网络层(ip地址)处理功能(协议栈),抛弃操作系统(Linux,BSD 等)提供的网络处理功能(协议栈),直接接管物理网卡,在用户态处理数据包,并且配合大页内存和 NUMA 等技术,大幅提升了网络性能。有论文做过实测,10G 网卡使用 Linux 网络协议栈只能跑到 2G 多,而 DPDK 分分钟跑满。
### 用户态网络栈
上篇文章我们已经说到,Unix 进程在网络数据包过来的时候,要进行一次上下文切换,需要分别读写一次内存,当系统网络栈处理完数据把数据交给用户态的进程如 Nginx 去处理还会出现一次上下文切换,还要分别读写一次内存。夭寿啦,一共 1200 个 CPU 周期呀,太浪费了。
而用户态协议栈的意思就是把这块网卡完全交给一个位于用户态的进程去处理,CPU 看待这个网卡就像一个假肢一样,这个网卡数据包过来的时候也不会引发系统中断了,不会有上下文切换,一切都如丝般顺滑。当然,实现起来难度不小,因为 Linux 还是分时系统,一不小心就把 CPU 时间占完了,所以需要小心地处理阻塞和缓存问题。
### NUMA
NUMA 来源于 AMD Opteron 微架构,其特点是将 CPU 直接和某几根内存使用总线电路连接在一起,这样 CPU 在读取自己拥有的内存的时候就会很快,代价就是读取别 U 的内存的时候就会比较慢。这个技术伴随着服务器 CPU 核心数越来越多,内存总量越来越大的趋势下诞生的,因为传统的模型中不仅带宽不足,而且极易被抢占,效率下降的厉害。
![img](03.assets/2018-11-19-15426064316556.jpg)
> NUMA 利用的就是电子计算机(图灵机 + 冯·诺依曼架构)天生就带的涡轮:局部性。 `涡轮:汽车发动机加上涡轮,可以让动力大增油耗降低`
## 细说大页内存
### 内存分页
为了实现虚拟内存管理机制,前人们发明了内存分页机制。这个技术诞生的时候,内存分页的默认大小是 4KB,而到了今天,绝大多数操作系统还是用的这个数字,但是内存的容量已经增长了不知道多少倍了。
### TLB miss
TLB(Translation Lookaside Buffers)转换检测缓冲区,是内存控制器中为增虚拟地址到物理地址的翻译速度而设立的一组电子元件,最近十几年已经随着内存控制器被集成到了 CPU 内部,每颗 CPU 的 TLB 都有固定的长度。
如果缓存未命中(TLB miss),则要付出 20-30 个 CPU 周期的带价。假设应用程序需要 2MB 的内存,如果操作系统以 4KB 作为分页的单位,则需要 512 个页面,进而在 TLB 中需要 512 个表项,同时也需要 512 个页表项,操作系统需要经历至少 512 次 TLB Miss 和 512 次缺页中断才能将 2MB 应用程序空间全部映射到物理内存;然而,当操作系统采用 2MB 作为分页的基本单位时,只需要一次 TLB Miss 和一次缺页中断,就可以为 2MB 的应用程序空间建立虚实映射,并在运行过程中无需再经历 TLB Miss 和缺页中断。
### 大页内存
大页内存 HugePage 是一种非常有效的减少 TLB miss 的方式,让我们来进行一个简单的计算。
2013 年发布的 Intel Haswell i7-4770 是当年的民用旗舰 CPU,其在使用 64 位 Windows 系统时,[可以提供 1024 长度的 TLB](https://www.7-cpu.com/cpu/Haswell.html),如果内存页的大小是 4KB,那么总缓存内存容量为 4MB,如果内存页的大小是 2MB,那么总缓存内存容量为 2GB。显然后者的 TLB miss 概率会低得多。
DPDK 支持 1G 的内存分页配置,这种模式下,一次性缓存的内存容量高达 1TB,绝对够用了。
不过大页内存的效果没有理论上那么惊人,DPDK 实测有 10%~15% 的性能提升,原因依旧是那个天生就带的涡轮:局部性。
冯·诺依曼架构中,指令和数据均存储在内存中,彻底打开了计算机“通用”的大门。这个结构中,“线性数组”内存天生携带了一个涡轮:局部性。
## 局部性分类
### 空间局部性
空间局部性是最容易理解的局部性:如果一段内存被使用,那么之后,离他最近的内存也最容易被使用,无论是数据还是指令都是这样。举一个浅显易懂的例子:
循环处理一个 Array,当处理完了 [2] 之后,下一个访问的就是 [3],他们在内存里是相邻的。
### 时间局部性
如果一个变量所在的内存被访问过,那么接下来这一段内存很可能被再次访问,例子也非常简单:
$a = [];
if ( !$b ) {
$a[] = $b;
}
在一个 `function` 内,一个内存地址很可能被访问、修改多次。
## 乐观
“乐观”作为一种思考问题的方式广泛存在于计算机中,从硬件设计、内存管理、应用软件到数据库均广泛运用了这种思考方式,并给我们带来了十分可观的性能收益。
### 乐观的 CPU
第一篇文章中的 L1 L2 L3 三级缓存和第二篇文章中的分支预测与流水线,均是乐观思想的代表。
### 乐观的虚拟内存
虚拟内存依据计算机内存的局部性,将磁盘作为内存的本体,将内存作为磁盘的缓存,用很小的性能代价带来了数十倍并发进程数,是乐观思想的集大成者。
### 乐观的缓存
Java 经典面试题 LRU 缓存实现,也是乐观思想的一种表达。
同样,鸟哥的 [yac](http://www.laruence.com/2013/03/18/2846.html) 也是这一思想的强烈体现。
##### 设计 Yac 的经验假设
> 1. 对于一个应用来说, 同名的Cache键, 对应的Value, 大小几乎相当.
> 2. 不同的键名的个数是有限的.
> 3. Cache的读的次数, 远远大于写的次数.
> 4. Cache不是数据库, 即使Cache失效也不会带来致命错误.
##### Yac 的限制
> 1. key的长度最大不能超过48个字符. (我想这个应该是能满足大家的需求的, 如果你非要用长Key, 可以MD5以后再存)
> 2. Value的最大长度不能超过64M, 压缩后的长度不能超过1M.
> 3. 当内存不够的时候, Yac会有比较明显的踢出率, 所以如果要使用Yac, 那么尽量多给点内存吧.
### 乐观锁
乐观锁在并发控制和数据库设计里都拥有重要地位,其本质就是在特定的需求下,假定不会冲突,冲突之后再浪费较长时间处理,比直接每次请求都浪费较短时间检测,总体的性能高。乐观锁在算法领域有着非常丰富而成熟的应用。
### 乐观的分布式计算
分布式计算的核心思想就是乐观,由 95% 可靠的 PC 机组成的分布式系统,起可靠性也不会达到 99.99%,但是绝大多数场景下,99% 的可靠性就够了,毕竟拿 PC 机做分布式比小型机便宜得多嘛。下一篇文章我会详细介绍分布式计算的性能之殇,此处不再赘述。
### 乐观的代价
出来混,早晚是要还的。
乐观给了我们很多的好处,总结起来就是一句话:以微小的性能损失换来大幅的性能提升。但是,人在河边走,哪有不湿鞋。每一个 2015 年 6 月入 A 股的散户,都觉得大盘还能再翻一番,岂不知一周之后,就是股灾了。
乐观的代价来自于“微小的性能损失”,就跟房贷市场中“微小的风险”一样,当大环境小幅波动的时候,他确实能承担压力,稳住系统,但是怕就怕突然雪崩:
1. 虚拟内存中的内存的局部性突然大幅失效,磁盘读写速度成了内存读写速度,系统卡死
2. 分布式数据库的六台机器中的 master 挂了,系统在一秒内选举出了新的 master,你以为系统会稳定运行?master 挂掉的原因就是压力过大,这样就会导致新的 master 瞬间又被打挂,然后一台一台地继续,服务彻底失效。例如:[「故障说明」对六月六日 LeanCloud 多项服务发生中断的说明](https://forum.leancloud.cn/t/leancloud/914)
分布式计算是这些年的热门话题,各种大数据框架层出不穷,容器技术也奋起直追,各类数据库(Redis、ELasticsearch、MongoDB)也大搞分布式,可以说是好不热闹。分布式计算在大热的同时,也存在着两台机器也要硬上 Hadoop 的“面向简历编程”,接下来我就剖析一下分布式计算的本质,以及我的理解和体会。
## 分布式计算的本质
分布式计算来源于人们日益增长的性能需求与落后的 x86 基础架构之间的矛盾。恰似设计模式是面向对象对现实问题的一种妥协。
### x86 服务器
x86 服务器,俗称 PC 服务器、微机服务器,近二十年以迅雷不及掩耳盗铃之势全面抢占了绝大部分的服务器市场,它和小型机比只有一个优势,其他的全是缺点,性能、可靠性、可扩展性、占地面积都不如小型机,但是一个优势就决定了每年 2000 多亿美元的 IDC 市场被 x86 服务器占领了 90%,这个优势就是**价格**。毕竟有钱能使磨推鬼嘛。
现有的分布式计算,无论是 Hadoop 之类的大数据平台,还是 HBase 这样的分布式数据库,无论是 Docker 这种容器排布,还是 Redis 这种朴素分布式数据库,其本质都是因为 x86 的扩展性不够好,导致大家只能自己想办法利用网络来自己构建一个宏观上更强性能更高负载能力的计算机。
### x86 分布式计算,是一种新的计算机结构。
基于网络的 x86 服务器分布式计算,其本质是把网络当做总线,设计了一套新的计算机体系结构:
- 每一台机器就等于一个运算器加一个存储器
- master 节点就是控制器加输入设备、输出设备
### x86 分布式计算的弱点
上古时代,小型机的扩展能力是非常变态的,到今天,基于小型机的 Oracle 数据库系统依旧能做到惊人的性能和可靠性。实际上单颗 x86 CPU 的性能已经远超 IBM 小型机用的 PowerPC,但是当数量来到几百颗,x86 服务器集群就败下阵来,原因也非常简单:
1. 小型机是专门设计的硬件和专门设计的软件,只面向这种规模(例如几百颗 CPU)的计算
2. 小型机是完全闭源的,不需要考虑扩展性,特定的几种硬件在稳定性上前进了一大步
3. x86 的 IO 性能被架构锁死了,各种总线、PCI、PCIe、USB、SATA、以太网,为了个人计算机的便利性,牺牲了很多的性能和可靠性
4. 小型机使用总线通信,可以实现极高的信息传递效率,极其有效的监控以及极高的故障隔离速度
5. x86 服务器基于网络的分布式具有天然的缺陷:
1. 操作系统决定了网络性能不足
2. 网络需要使用事件驱动处理,比总线电路的延迟高几个数量级
3. PC 机的硬件不够可靠,故障率高
4. 很难有效监控,隔离故障速度慢
## x86 分布式计算的基本套路
### Google 系大数据处理框架
2003 年到 2004 年间,Google 发表了 MapReduce、GFS(Google File System)和 BigTable 三篇技术论文,提出了一套全新的分布式计算理论。MapReduce 是分布式计算框架,GFS(Google File System)是分布式文件系统,BigTable 是基于 Google File System 的数据存储系统,这三大组件组成了 Google 的分布式计算模型。
Hadoop、Spark、Storm 是目前最重要的三大分布式计算系统,他们都是承袭 Google 的思路实现并且一步一步发展到今天的。
MapReduce 的基本原理也十分简单:将可以并行执行的任务切分开来,分配到不同的机器上去处理,最终再汇总结果。而 GFS 是基于 Master-Slave 架构的分布式文件系统,其 master 只扮演控制者的角色,操控着所有的 slave 干活。
### Redis、MongoDB 的分布式
Redis 有两个不同的分布式方案。Redis Cluster 是官方提供的工具,它通过特殊的协议,实现了每台机器都拥有数据存储和分布式调节功能,性能没有损失。缺点就是缺乏统一管理,运维不友好。Codis 是一个非常火的 Redis 集群搭建方案,其基本原理可以简单地描述如下:通过一个 proxy 层,完全隔离掉了分布式调节功能,底层的多台机器可以任意水平扩展,运维十分友好。
MongoDB 官方提供了一套完整的分布式部署的方案,提供了 mongos 控制中心,config server 配置存储,以及众多的 shard(其底层一般依然有两台互为主从强数据一致性的 mongod)。这三个组件可以任意部署在任意的机器上,MongoDB 提供了 master 选举功能,在检测到 master 异常后会自动选举出新的 master 节点。
## 问题和瓶颈
人们费这么大的劲研究基于网络的 x86 服务器分布式计算,目的是什么?还不是为了省钱,想用一大票便宜的 PC 机替换掉昂贵的小型机、大型机。虽然人们已经想尽了办法,但还是有一些顽固问题无法彻底解决。
### master 失效问题
无论怎样设计,master 失效必然会导致服务异常,因为网络本身不够可靠,所以监控系统的容错要做的比较高,所以基于网络的分布式系统的故障恢复时间一般在秒级。而小型机的单 CPU 故障对外是完全无感的。
现行的选举机制主要以节点上的数据以及节点数据之间的关系为依据,通过一顿猛如虎的数学操作,选举出一个新的 master。逻辑上,选举没有任何问题,如果 master 因为硬件故障而失效,新的 master 会自动顶替上,并在短时间内恢复工作。
而自然界总是狠狠地打人类的脸:
1. 硬件故障概率极低,大部分 master 失效都不是因为硬件故障
2. 如果是流量过大导致的 master 失效,那么选举出新的 master 也无济于事:提升集群规模才是解决之道
3. 即使能够及时地在一分钟之内顶替上 master 的工作,那这一分钟的异常也可能导致雪崩式的 cache miss,从磁盘缓存到虚拟内存,从 TLB 到三级缓存,再到二级缓存和一级缓存,全部失效。如果每一层的失效会让系统响应时间增加五倍的话,那最终的总响应时长将是惊人的。
### 系统规模问题
无论是 Master-Slave 模式还是 Proxy 模式,整个系统的流量最终还是要落到一个特定的资源上。当然这个资源可能是多台机器,但是依旧无法解决一个严重的问题:系统规模越大,其本底性能损失就越大。
这其实是我们所在的这个宇宙空间的一个基本规律。我一直认为,这个宇宙里只有一个自然规律:熵增。既然我们这个宇宙是一个熵增宇宙,那么这个问题就无法解决。
## 超级计算机
超级计算机可以看成一个规模特别巨大的分布式计算系统,他的性能瓶颈从目前的眼光来看,是超多计算核心(数百万)的调节效率问题。其本质是通信速率不够快,信息传递的太慢,让数百万核心一起工作,传递命令和数据的工作占据了绝大多数的运行时间。
## 神经网络
深度学习这几年大火,其原因就是卷积神经网络(CNN)造就的 AlphaGo 打败了人类,计算机在这个无法穷举的游戏里彻底赢了。伴随着 Google 帝国的强大推力,深度学习,机器学习,乃至人工智能,这几个词在过去的两年大火,特别是在中美两国。现在拿手机拍张照背后都有机器学习你敢信?
机器学习的瓶颈,本质也是数据交换:机器学习需要极多的计算,而计算速度的瓶颈现在就在运算器和存储器的通信上,这也是显卡搞深度学习比 CPU 快数十倍的原因:显存和 GPU 信息交换的速度极快。
## 九九归一
分布式系统的性能问题,表现为多个方面,但是归根到底,其原因只是一个非常单纯的矛盾:人们日益增长的性能需求和数据一致性之间的矛盾。一旦需要强数据一致性,那就必然存在一个限制性能的瓶颈,这个瓶颈就是信息传递的速度。
同样,超级计算机和神经网络的瓶颈也都是信息传递的速度。
### 那么,信息传递速度的瓶颈在哪里呢?
我个人认为,信息传递的瓶颈最表层是人类的硬件制造水平决定的,再往底层去是冯·诺依曼架构决定的,再往底层去是图灵机的逻辑模型决定的。可是图灵机是计算机可行的理论基础呀,所以,还是怪这个熵增宇宙吧,为什么规模越大维护成本越高呢,你也是个成熟的宇宙了,该学会自己把自己变成熵减宇宙了。
【全系列完结】
# How to Build an 8-Bit Computer
> How to Build an 8-Bit Computer : 18 Steps (with Pictures) - Instructables
> https://www.instructables.com/id/How-to-Build-an-8-Bit-Computer/
Building an 8-bit TTL computer sounds like a daunting and complicated task, or at least it did to me when I started out on my journey to understand the architecture of a basic CPU. When it comes down to it, a CPU is fairly simple in operation once you learn the fundamentals behind all of its processes. This project is intended to help anyone interested in building their own computer and gaining the wonderful knowledge that comes along with the process. Don't be afraid to try, you can only learn.
This project will start off by describing the basics of electronics. After that, the fundamentals of binary and boolean logic will be described. Lastly we will then move onto the function of the various parts of a simple-as-possible computer (with a few modifications) as described in Malvino's text *Digital Computer Electronics*. This means that the end product of this Instructable will be a computer that you can program with a unique instruction set. This project also leaves many of the design aspects of the computer up to you and serves as a guide for building your own computer. This is because there are many ways to approach this project. If you already have a sound understanding of boolean logic and the workings of binary feel free to skip to the meat of the project. I hope that you all enjoy and get something out of a build like this, I know that I sure did.
For this project you will need:
1.) A power supply
2.) Breadboards + lots of wires
3.) LED's for output
4.) Various logic IC's (discussed later)
5.) Free time
6.) A willingness to mess up and learn from mistakes
7.) A lot of patience
Optional (but very useful):
1.) Oscilloscope
2.) Digital multimeter
3.) EEPROM programmer
4.) Sonic screwdriver
**Useful Links for a Project Like This:Digital Computer Electronics:**[**http://www.amazon.com/Digital-computer-electronics-Albert-Malvino/dp/007039861**](http://www.amazon.com/Digital-computer-electronics-Albert-Malvino/dp/0070398615)
**TTL Cookbook:**[**http://www.amazon.com/TTL-Cookbook-Understanding-Transistor-Transistor-Integrated/dp/B0049UUV38**](http://www.amazon.com/TTL-Cookbook-Understanding-Transistor-Transistor-Integrated/dp/B0049UUV38)
## Step 1: What Is a Computer?
This may seem like a very simplistic question that does not need answering when, in fact, it is a question that many people do not know the true answer to. Computers have existed a lot longer than the transistor in mechanical and theoretical form. The actual definition of a computer was thought up by a very intelligent individual by the name of Alan Turing. He described a machine that was termed the Turing Machine. Every computer that we use today, from the computer or cell phone that you are reading this on to supercomputers all can be classified as a Turing Machine at their most simplistic level.
What is a Turing Machine? A Turing Machine consists of 4 parts: the tape, head, table and state register. To visualize the operation of such a machine you first have to imagine a film strip spanning infinitely in each direction. Now imagine that each cell of this film strip can contain only one of a defined set of symbols (like an alphabet). For this example let us imagine that each cell can only contain either a "0" or a"1". These cells can be rewritten an infinite amount of time but retain their information indefinitely until they are changed again. The part of the Turing Machine known as the head can write symbols to the cells as well as either increment or decrement its position on the film strip by a given integer (whole number) of cells. The next part is the table which holds a given set of instructions for the head to execute such as "move right 4 cells" and "set cell to 1". The fourth and final part of a Turing Machine is its state register whose purpose is to hold the current state of the machine. The state includes the instruction as well as the current data on the tape.
That is how simple the operation of a computer is. When your computer operates, it is actually operating as a turing machine. It processes data held on your computer by a given set of instructions and algorithms. The computer described in this Instructable is a very simplistic model of a computer, but it still operates as one that you can program with a set of instructions that it will follow and execute.
**Useful Links:Wikipedia on Turing Machines:** [**http://en.wikipedia.org/wiki/Turing_machine**](http://en.wikipedia.org/wiki/Turing_machine)
## Step 2: An Introduction to Electronics
![An Introduction to Electronics](04.assets/FTMR3D8H1KHAAKH.png)
![An Introduction to Electronics](04.assets/F6BB2X9H1LWPS3R.jpg)
Before building an 8-bit computer, it is extremely useful to have a grasp on the elemental properties of electricity and analog circuitry. There are parts on the computer you will build will need analog components. There are many electronics self teaching guides available for a minimal cost that provide a crash-course in electrical engineering. I personally found *Electronics Self Teaching Guide* by Harry Kybet and Earl Boysen to be a wonderful book for tackling the world of analog electronics.
*Electronics Self Teaching Guide*: http://www.amazon.com/Electronics-Self-Teaching-Guide-Teaching-Guides/dp/0470289619/
Common Components:
**Resistor - Limits current, measured in ohms.Capacitor - Stores charge, can either be polar or non-polar (polar meaning that it must be placed in the correct direction to work). Measured in farads.Diode - Only allows current to flow in one direction, breaks down at a certain voltage when placed in the wrong direction.Transistor - A current gate that is controlled by a third pin that acts as a mediator. There are many types of transistors, but here we will be talking about the BJT (bipolar junction transistor) which comes in two types: NPN and PNP.**
Current, voltage and resistance go hand-in-hand in a circuit. The relation between the three can be expressed with Ohm's law: V = IR. In other words, Voltage equals the current in amperes multiplied by the resistance in ohms. Ohm's law is one of the most important formulas in electronics and it is well worth knowing off of the top of your head.
To apply Ohm's law you need to know the resistance of a circuit. To find the value of a resistor you have to use its color code. The resistor color code is based upon the visible spectrum and can be memorized in many different fashions. For those who don't care to memorize it, there is a plethora of tools that exist to help you find the correct value for your resistor. To calculate total resistance in a circuit you need two formulas for two different configurations of resistors: series and parallel. In series one resistor follows the other one, whereas in parallel they work alongside each other. In series the formula is very simple:
**Resistors in Series: R(total) = R(1) + R(2) + . . . + R(N)**
Meaning that you just have to add up the values of the resistors.
**Resistors in Parallel: R(total) = 1/{ 1/R(1) + 1/R(2) + . . . + 1/R(N) }**
A good tool to find resistance from color code: http://www.csgnetwork.com/resistcolcalc.html
It is easier to understand the formula for resistors in parallel if you think of the resistors as working together like two people working together on a project. The same formula is used for word problems where you are given the rate at which two person operate and you must find out how fast their project will be completed if the work together.
To find how much current is supplied to a given component with a given resistance value you would simply plug in the resistance and voltage values into Ohm's law and solve for I. For instance:
A light is in a circuit and and two 1K (one thousand ohm) resistors are placed in front of it in parallel. With a power supply of 9 volts, how much current is supplied to the light?
1.) Calculate R(total):
**R(total) = 1/( 1/1000 + 1/1000 ) = 1/( 2/1000) = 1000/2 = 500 ohms**
2.) Calculate current using Ohm's law:
**9 = I \* 500**
**I = 9/500 = .018 A = 18 mA (milliamps)**
You can also arrange resistors in a circuit to regulate voltage. This is called a voltage divider and involves two resistors in series. The voltage output of the two resistors is at their junction. For a better idea, look at the picture that I have attached. In this arrangement the formula for voltage output is:
**V(out) = V(source) \* R(2)/{ R(1) + R(2) }**
Capacitors will be useful in your computer with the construction of the clock. The clock is simply a circuit that turns on and off at a constant rate. Just like resistors, capacitors have two formulas for finding the total value for both series and parallel configurations.
**Series: C(total) = 1/{ 1/C(1) + 1/C(2) + . . . + 1/C(N) }Parallel: C(total) = C(1) + C(2) + . . . + C(N)**
The rate at which a capacitor charges depends upon the resistance of the circuit before (or after if you are discharging) the capacitor as well as its capacitance. The charging of a capacitor is measured in time constants. It takes 5 time constants to fully charge or discharge a capacitor. The formula for finding the time constant of a capacitor in seconds is:
**T(constant) = Resistance \* Capacitance**
Diodes are simple in operation and come in handy when building a TTL computer. They only allow current to flow in one direction. When they are placed in the correct direction they are what is called forward-biased. When they are reversed they break down at a certain voltage. When a diode is working against the current it is reverse-biased.
A Transistor operates like a valve that is operated by current. A BJT has three pins: the collector, the emitter and the base. For sake of simplicity in this step I will describe a NPN transistor in which current flows from the collector to the emitter. The current applied at the base controls how much of the current flows from the collector to the emitter. Transistors are ideal for many applications due to their ability to amplify a signal. This is because the current applied at the base of the transistor can be considerably less than the current controlled. This gain in current is called the current gain of the transistor, or beta. The formula for beta is:
**Beta = Current(Collector)/Current(Base)**
When a transistor is completely on it is said to be saturated. A boolean transistor is one that is either in its saturated or off state and never in between. This is the type of transistor that you will be dealing with mostly in digital electronics. Transistors form the logic gates needed for a computer to function. These will be described later.
**Useful Links:**
http://en.wikipedia.org/wiki/Resistor
http://en.wikipedia.org/wiki/Capacitor
http://en.wikipedia.org/wiki/Diode
http://en.wikipedia.org/wiki/Transistor
## Step 3: Binary Numbers
Today we are used to a worldwide numbering system that is based on the number ten. By that I mean that we have no numeral in our number system that is worth the value of ten and thus our number system is base ten.
Think of our number system as an odometer. An odometer counts from the lowest digit to the highest digit and then forces the next rotor in sequence to advance one place. For example:
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 0 <-- Carry to the next digit
Binary is base two, meaning that it only has two numerals and has no numeral for 2. Binary only has the numerals 0 and 1 or "off" and "on". To count in binary you simply apply the odometer technique:
0001b - 1
0010b - 2
0011b - 3
0100b - 4
0101b - 5
0110b - 6
0111b - 7
1000b - 8
etc . . .
There is another factor of our number system that makes it base ten; as we move higher in digits the weight of numerals increase by a power of ten. For example 1 = 10^0, 10 = 10^1, 100 = 10^2, etc . . . In binary, things of course are base two and as such, each successive numeral is another power of two. 1b = 1 = 2^0, 10b = 2 = 2^1, 100b = 4 = 2^2, etc . . .
To convert a decimal number to binary there is a simple trick known as double-dabble that makes the process a lot more easy:
Say we want to convert 13 to a binary number, we start by dividing 13 by two and writing down the remainder. Then directly above it you write down the resulting number without the remainder (6 in this case) and divide that by two and write down the remainder above the previous one. You continue this process until you reach either a 1 or a 0. At the end you read from the top down to get the result.
1/2 = 0 R1 < Read from top to bottom. The result is 1101 or 2^0 + 0 + 2^2 + 2^3 = 1 + 0 + 4 + 8 = 13. This is called a binary word.
3/2 = 1 R1 <
6/2 = 3 R0 <
13/2 = 6 R1 <
Hexadecimal is used very often with binary. Hexadecimal is base 16 and contains the numerals 0-9 and a-f. One hexadecimal numeral is used to describe one nibble or four bits of data. A bit is a single 1 or 0 of binary. A nibble can count from 0 to 15 (0000 to 1111) before the next bit is in the next nibble. Two nibbles together is a byte or 8 bits. Since the first numeral is 2^0, the last numeral is weighted 2^7. Therefore a byte can be anywhere in the range from 0 to 255. To express the byte 00101110 (46 in decimal) in hexadecimal you would first separate the two nibbles into 0010 and 1110. The first nibble has a value of 2, and the second one has a value of E (or 14 in decimal). Therefore the byte 00101110 in hexadecimal would be 2E.
**Useful Links:**
http://en.wikipedia.org/wiki/Binary_numeral_system
http://en.wikipedia.org/wiki/Hexadecimal
## Step 4: Logic Gates
A computer consists of thousands of logic gates arranged to carry out certain functions. A logic gate is a component in digital electronics whose output depends on the state of its inputs. Most logic gates have two inputs and one output. You can think of logic gates as the decision-makers in digital electronics. The six main logic gates used in digital electronics are:
**AND Gate: Output is high when all if its inputs are high.OR Gate: Output is high when any of its inputs are high.NOT Gate: Only has one input. Output is high when its input is low.NAND Gate: Output is high unless all of its inputs are high.NOR Gate: Output is high when none of its inputs are high.XOR Gate: Output is high when an odd number of inputs are high.**
**Tri-State Buffer: A buffer that is controlled by a third logic signal.**
It is important to mention now the difference between a high "1" signal and a low "0" signal. A high signal can either be a connection to positive voltage or it can be a floating input. A floating input is one that is not connected to any output. An example of a floating input would be one that is not connected at all or one that is connected to the output of a 3-state buffer that is not activated. A low signal is present when an input is at ground.
Logic gates can be fed into each other to produce almost any function imaginable. For instance, two NOR gates can be fed into each other to store one bit of data in a RS_NOR latch while power is supplied to the circuit.
## Step 5: Binary Counting (The Program Counter)
One of the most essential parts to a computer is its program counter. The program counter provides the computer with the current address of the instruction to be executed. In order for the program counter to work, however, it needs to count in binary. To do this JK flip flops are used. A flip-flop is an arrangement of logic gates that stores one bit (like the RS_NOR latch described in the logic gates step). A JK flip-flop changes its state when its clock pulse input goes high and then low again (its J and K inputs also have to be high). In other words, whenever a JK flip flop gets the falling edge of a clock pulse its state changes from either a "0" to a "1" or from a "1" to a "0".
If you connect the output of one JK flip flop to another and cascade them the result is a binary counter that acts like an odometer. This is because as the first JK flip flop in the sequence goes high, and then low, it triggers the next one in the sequence. The clock's frequency (how many times it turns on and off a second) is halved with every successive addition of a JK flip flop. That is why a JK flip-flop is also called a divide-by-two circuit. The resulting pattern for four JK flip flops will be 0000, 0001, 0010, 0011, 0100, etc . . .
For the simple-as-possible computer described in this Instructable, however, there are a few more functions that you need in order to make the computer operational. In order for the computer to be able to restart its program it needs the ability to clear or set all of its outputs to zero. The program counter also needs the ability to load a binary word for the JMP op code which allows the computer to jump to a certain instruction. Logic gates are used to achieve this goal. Fortunately for us binary counters come in convenient chips with all of the functions that you need.
## Step 6: Registers
Registers:
Registers could potentially be the most important part of a computer. A register temporarily stores a value during the operation of a computer. The 8-bit computer described in this Instructable has two registers attached to its ALU, a register to store the current instruction and a register for the output of the computer.
Depending on the chip, a register will have 2 or 3 control pins. The registers that we will be using have two control pins: output enable and input enable (both active when low). When the output enable pin is connected to ground the currently stored binary word is sent out across the output pins. When the input pin is connected to ground the binary word present on the input pins is loaded into the register.
An example of the use of a register on a computer is the accumulator on the ALU (arithmetic logic unit that performs mathematical operations). The accumulator is like the scratchpad for the computer that stores the output of the ALU. The accumulator is also the first input for the ALU. The B register is the second input. For an addition operation, the first value is loaded into the accumulator. After that the second value to be added to the first value is loaded into the B register. The outputs of the accumulator and B register are fused open and are constantly feeding into the ALU. The final step for addition is to transfer the output of the operation into the Accumulator.
Registers all operate on a shared data line called the bus. The bus is a group of wires equal in number to the architecture of any CPU. This is really putting the horse before the cart considering bus width is the defining measurement for CPU architecture. Since a digital 1 means positive voltage, and a 0 means grounding, it would be impossible to have all registers share the same bus without giving them the ability to selectively connect and disconnect from the bus. Luckily for us, there is a third state between 1 and 0 that is ambivalent to current imput that works great for this. Enter the tri-state buffer: a chip that allows you to selectively connect groups of wires to a bus. Using some of these tri-state-buffers, you can have every register and chip on the entire computer needing of communication share the same wires as a bus. In the case of my computer, it was an 8-wire wide band of breadboard slots that spanned the bottom pins of the breadboard. Experiment around with busses, since they carry all of the information from piece to piece in the computer a faulty buss could mean erroneous data that ripples down the line.
## Step 7: The ALU
The ALU (arithmetic logic unit) of a computer is the part that executes mathematical operations. For the SAP computer it will only need to have two functions: addition and subtraction. Adding and subtracting in binary works very similarly to addition and subtraction in decimal terms, for example:
1<-- Carry 1 1 <-- Carry Bits
05 0101
+05 +0101
10 1010
To add binary we need what is called a full-adder. A full-adder effectively adds one bit of binary to another with a carry in and carry out. The carry in of a full adder is like a third input for the addition process. They are used to chain multiple full-adders together. The carry out of a full-adder occurs when there is a pair of ones in the addition process. The carry out of a full adder is fed into the carry in to add multiple bits of binary. To construct a full adder you need two XOR gates, two AND gates and an OR gate.
To subtract binary we need to convert a number to its negative counterpart and add it to the number we are subtracting from. To do this we use what is called 2's compliment. To take the 2's compliment of a binary word you invert each bit (change every 0 to a 1 and every 1 to a 0) and add one.
5 = 0101, -5 = 1010+1 = 1011
Not used-->1 1
10 1010
+(-5) +1011
5 0101
To control the inversion of bits we use XOR gates with one normally low input. With one normally low input, the output is equivalent to the other input. When you set the control input high you invert the other input. If we couple this inversion with a bit sent to the carry in of the full adders a subtraction operation is the result.
## Step 8: Program Memory and RAM
The program memory of your computer will store the instructions to be executed. It will also act as RAM that can store values during the operation of the computer. The program memory consists of three main parts: the memory, the memory address register (MAR) and the multiplexer. The memory is a chip that has 16 bytes of storage. There is a four bit address that is fed into the memory that tells it what byte it should read or write. The MAR stores the current address for the byte to be read or written from the memory. It is constantly feeding into the memory chip unless the computer is in its programming state. A multiplexer allows you to choose between two inputs and output the given input. The multiplexer used in my computer allows you to select from two four bit inputs (the MAR and a manual input). When the computer is in its programming state the manual address is fed into the memory and allows you to program bytes into the computers memory at the address that you define.
## Step 9: Instruction Register
The instruction register of a computer stores the current instruction as well as an address that the instruction will operate on. It is a very simple component with a very important purpose. During the operation of the computer, the content of a given address in memory is transfered into the instruction register. In my computer the leftmost fout bits are the OP code or current instruction to be carried out. The right four bits, or lowest four bits, tell the computer what address to use for the operation. The first four bits constantly feed the OP code into the control matrix which tells the computer what to do for a given instruction. The rightmost four bits feed back into the computer so that the address can be transferred into the MAR or program counter.
## Step 10: Output Register
If a computer were to just feed the output of the bus to the operator, the readout would make little to no sense. This is why there is an output register whose purpose is to store values meant for output. The output for your computer can either be simple LED's that display raw binary, or you could have a display that reads out actual numbers on seven-segment displays. It all depends how much work you want to put into your computer. For my computer I am using some IV-9 Russian Numitron tubes for the output of my computer coupled with an Arduino to do the conversion from binary to decimal.
## Step 11: Clock
Every part in the computer has to be completely synchronized in order to function correctly. In order to do this your computer needs a clock or a circuit that has an output that turns on and off at a constant rate. The easiest way to do this is to use a 555 timer. The 555 timer is an extremely popular timer that was invented in the era of the emergence of the computer that is stille extremely popular with hobbyists today. To build the 555 circuit you need to know how one operates.
The clock for your computer should be relatively slow at first. 1Hz, or one cycle per second, is a good starting value. This allows you to view the operation of your computer and check for any errors. The 555 chip needs two resistors and a capacitor for operation. The two resistors determine how long the high and low pulses are as well as the overall frequency. The capacitor changes the pulse length for both. If you do not have any experience with 555 timers I recommend experimenting with them.
**Useful Links:**
**http://en.wikipedia.org/wiki/555_timer_IC**
## Step 12: Architecture
This is the step where everything comes together. It is time to design the architecture of your computer. The architecture is how the registers and different components of your computer are organized. The design aspect is completely up to you, although it helps to keep a goal in mind (what you want your computer to do) and a model to go off of. If you want to design your computer after mine it is completely fine. I modified the architecture of the SAP-1 found in *Digital Computer Electronics* for my 8-bit computer.
One design aspect to always keep in mind is how data is transferred between the various components of your computer. The most common method is to have a common "bus" for all of the data on the computer. The inputs and outputs of the registers, ALU, program counter and RAM all are connected to the computer's bus. The wires are arranged in order from least significant bit (1) to highest significant bit (128).
Any and all outputs that are connected to the bus have to be completely disconnected while inactive or else they would merge with each other and result in erroneous output. To do this we use Tri-state buffers to control the output of certain elements that output by default like the accumulator, ALU and actual input for the programming of the computer.
## Step 13: Control Matrix
The control matrix of a computer tells each individual part when to take input and output its value. There are multiple states of each operation in a computer. These states are triggered by a type of counter called a ring counter. A ring counter only has one bit high at a time and cycles through its outputs consecutively. For instance, if a ring counter has 4 outputs it will first have its first output active. At the next clock pulse it will set its second output high (and the first low). The next clock pulse will advance the bit one output higher and so on. These stages are called T states. The computer in this Instructable uses 6 T states for the operation of one command. The first three T states are what is called the fetch cycle in which the current instruction is fetched and placed into the instruction register. The program counter is also incremented by one. The second set of three T states depends on what OP code is fed into the control matrix from the instruction register. The T states are as follows:
**T1: The contents of the program counter are transferred into the memory address register. (Address State)T****2: The program counter is incremented by one. (Increment State)**
**T3: The addressed byte in the program memory is transfered into the instruction register. (Memory State)**
**T4: Dependent on what command is being executed.**
**T5: Dependent on what command is being executed.**
**T6: Dependent on what command is being executed.**
There are two primary ways to create a control matrix: using discrete logic and using ROM's. The ROM method is the easiest and most efficient. Using discrete logic involves designing a massive logic schematic that will output the correct control words for your computer based on an OP code input. ROM stands for read-only-memory. There are several types of ROM's that you can consider for use in your build. For my computer I originally used EEPROM (electronically erasable programmable ROM) but then shifted to NVRAM (non-volatile random access memory) after the EEPROM chips failed to write. I do not recommend NVRAM as it is meant for random access memory and not permanent storage. EEPROM is the most efficient solution in my opinion.
The control matrix will have three ROM chips each having at least 32 addresses of 8 bit storage (as well as the timing and counting elements). The binary word that is sent out from the control matrix is called the control ROM and contains all of the control bits for every component of your computer. You want to be sure to organize the control bits and know their order. For no operation you want a control word that renders every part of the computer inactive (except the clock of course). The control word for the computer described in this Instructable is 16 bits in length and is stored in two of the control ROM chips. The first three addresses of the control ROM chips hold the control words for the fetch cycle. The rest of the addresses on the chip hold the control words in pairs of three for each OP code. The third ROM chip holds the memory location for the start of the control word sequence for each OP code and is addressed by the OP code itself. For instance, in my computer if you give the control the OP code 0110 it will output binary 21, which is the address of the start of the JMP command. There is an 8-bit counter in between the OP ROM and the control ROM's that counts from 0-2 (first three T states) then on the third T state loads the address outputted by the OP ROM and counts from that position until the T1 state clears the counter again. The ring and binary counter for the control matrix are controlled by an inversion of the clock pulse so that control words are present when the rising clock pulse goes to the elements of the computer. The entire process in order is as follows:
**1.) T1 state clears the counter to 0, the control word stored at 0 is sent out2.) The clock goes high and the address state takes place3.) The clock goes low and in turn the control counter increments and control word 1 is sent out4.) The clock goes high and the increment cycle takes place5.) The clock goes low and the control counter increments to 2, control word 2 is sent out6.) The clock goes high and the memory state takes place and the OP code arrives at the instruction register, T3 is also active which means on the next low clock pulse the OP control address will be loaded7.) The clock goes low and loads the counter with the address for the first of the three control words for the given OP code8.) T4, T5 and T6 execute the OP code9.) T1 resets the counter, the process continues until a HLT OP is received. The HLT command stops the clock.**
## Step 14: Microprogramming
Now is the part where you decide what commands you want your computer to be capable of. I gave my computer 6 unique operations that would give it the basic programming functions that I would need. The commands that you will program into your computer are what is called Assembly language. Assembly is one of the earliest programming languages and can still be used on computers today. Commands in the language include loading the accumulator, adding, moving, outputting and storing variables. Each command has its own 4-bit OP code in this 8-bit computer. The commands that I chose for my computer are:
NOP: No operation. (0000)
LDA: Load the accumulator with the value at this address. (0001)
ADD: Add the value at the specified address to the value in the accumulator. (0010)
SUB: Subtract the value at the specified address from the value in the accumulator. (0011)
STO: Store the accumulator's contents at the specified address. (0100)
OUT: Store the accumulator's contents in the output register so that the operator can see it. (0101)
JMP: Jump to a certain instruction in memory at the specified address. (0110)
HLT: Stop the operation of the computer. (0111)
To determine what control words need to be sent out for each OP you need to know what bits have to be active during each T state. For my computer I organized the bits as follows (an underline denotes an active-low bit):
CE CO J MI RO II IO OI BI EO SU AI AO RI HLT X
CE - Count Enable (enables the program counter's clock input)
CO - Clock out enable
J - Jump enable
MI - MAR Input
RO - Program memory out
II - Instruction register in
IO - Instruction register out
OI - Output register in
BI - B register in
EO - ALU output enable
SU - Subtract
AI - Accumulator in
AO - Accumulator output enable
RI - Program memory in
HLT - Halt
X - Not used
Here are what bits should be active for each T state for a given instruction as well as the address that they should be in the control ROM:
Fetch:
0: CO, MI - The program counter outputs into the MAR
1: CE - The counter is enabled for the next clock pulse
2: RO, II - The addressed byte is outputted from RAM into the instruction register
NOP:
3: X
4: X
5: X
LDA:
6: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
7: RO, AI - The addressed byte is outputted from memory into the accumulator
8: X
ADD:
9: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
10: RO, BI - The addressed byte is outputted from memory into the accumulator
11: EO, AI - The sum of the accumulator and the B register is loaded into the accumulator
SUB:
12: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
13: RO, BI - The addressed byte is outputted from memory into the accumulator
14: AI, SU, EO - The difference of the accumulator and the B register is loaded into the accumulator
STO:
15: IO, MI - The address in the instruction register is transfered to the MAR (lowest four bits)
16: AO, RO, RI - The accumulator outputs into the program memory at the addressed location (RO and RI have to be active for a write on the chip that I used)
17: X
OUT:
18: OI, AO - The accumulator outputs into the output register
19: X
20: X
JMP:
21: J, IO - The instruction register loads the program counter with its lowest four bits
22: X
23: X
HLT:
24: HLT - A halt signal is sent to the clock
25: X
26: X
Your OP ROM contains multiples of three at each memory location. This is of course because each cycle takes three execution states. Therefore the addressed data for your OP ROM will be:
0 - 3
1 - 6
2 - 9
3 - 12
4 - 15
5 - 18
6 - 21
7 - 24
To program your choice of chip you have many different options. You could buy an EEPROM and EPROM programmer, but they usually cost a considerable amount of money. I built a breadboard programmer for my ROM that is operated by moving wires around and controlling the write and read enable pins by push buttons. Later I simplified the process and designed an Arduino programmer for my NVRAM specifically. I'll attach the code as it can be easily modified to program almost any parallel memory chip that you would use for this project.
## Step 15: Buying Parts
The great thing about building an 8-bit computer is that most parts will cost you less than a dollar a piece if you buy them from the correct place. I purchased 90% of my parts from Jameco Electronics and I have been completely satisfied with their services. The only parts I have really bought from anywhere else are the breadboards and breadboard wires (and the Numitron tubes). These can be found considerably cheaper on sites like Amazon. Always be sure to make sure the parts that you are ordering are the correct ones. Every part that you buy should have a datasheet available online that explains all of the functions and limitations of the item that you are buying. Make sure to keep these organized as you will be using many datasheets in the construction of your computer. To help you with your computer I will list the parts that I used for mine:
4-Bit Counter:
74161 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74161&langId=-1&storeId=10001&productId=49664&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
4-Bit Register (I use two for each 8-bit register):
74LS173 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74LS173&langId=-1&storeId=10001&productId=46922&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
2-1 Multiplexer:
74LS157 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_46771_-1
16x8 RAM (output needs to be inverted):
74189 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74189&langId=-1&storeId=10001&productId=49883&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
Full Adders:
74LS283 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=74LS283&langId=-1&storeId=10001&productId=47423&search_type=all&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
Tri-State Buffers:
74S244 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_910750_-1
XOR Gates:
74LS86 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295751_-1
AND Gates:
74LS08 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295401_-1
NOR Gates:
74LS02 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_283741_-1
Inverters:
74LS04 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_283792_-1
Ring Counter:
CD4029 - http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?freeText=4029&langId=-1&storeId=10001&productId=12925&search_type=jamecoall&catalogId=10001&ddkey=http:StoreCatalogDrillDownView
JK Flip-Flops:
74LS10 - http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_295427_-1
## Step 16: Construction
Here is where the patience really comes in. I chose using a breadboard for the actual computer, but there are many other methods out there (such as wire-wrapping) that will work just as well. To make things a lot more simple I included a block diagram for the actual schematic of my computer. I did not however include part numbers or pin numbers. I believe that this will make things more simple and open for creativity. The 4-bit program counter output, MAR input and instruction register output are all connected to the four least significant bits of the computer's bus.
The second diagram shown is the control logic for the operation end of the computer. The controls are designed so that toggles can be an input for the computer. RS_NOR latches are placed in front of the toggle switches to debounce them. Toggle switches often have dirty connections that may bounce from an on to an off state and provide more pulses than you want. Adding a flip-flop to the output of a toggle eliminates the extra pulses. This would be extremely useful when using the manual clock option. You would not want to flip the switch and initiate 8 clock pulses. The read/write button writes the active input byte to the addressed memory. By changing the default control word input to RAM to two low RO and RI bits initiating a write cycle. The run/program switch changes which input is active on the memory address multiplexer. The JK flip flop after the 555 means that when the computer is run, it will not start on the middle of a clock pulse. A low HLT signal will stop the clock from passing on either the manual clock or 555. And finally, the run/clear switch is connected to all of the clear pins on the computer such as those on the registers and counters.
## Step 17: Programming
Now that the computer is done, it can be programmed to carry out instructions. To do this you first have to put the computer into its program setting by flipping the run/program toggle switch into the program position. After that you select addresses starting at 0 and going to 15 and insert the needed data for your program. For instance, to start with 5 and add 4 with every output the program would be as follows:
Address - Data:
0000 - 00010111 LDA 7: Load the accumulator with the value stored at memory address 7 (5)
0001 - 00101000 ADD 8: Add value stored at memory address 8 (4)
0010 - 01010000 OUT: Output the accumulator
0011 - 01100001 JMP 1: Jump to instruction 1
0100 - X
0101 - X
0110 - X
0111 - 00000101 5
1000 - 00000100 4
1001 - X
1010 - X
1011 - X
1100 - X
1101 - X
1110 - X
1111 - X
## Step 18: Going Further
I hope you enjoyed this Instructable and, most of all, I hope that you got something out of it. You can consider all of this hard work an incredibly valuable learning experience that will give you a better understanding of electronics, computers and programming. In the end you will also have something very cool to show for all of your hard work as well.
After constructing your first 8-bit computer you can go further and add more functionality. The ALU used in this computer is very simplistic in operation and true ALU's today have a myriad of functions such as bit-shifting and logical comparisons. Another important aspect to move onto is conditional branching. Conditional branching means that an instruction depends on the current state of flags set by the ALU. These flags change as the accumulator's contents become negative or are equal to zero. This allows for a much more expansive possibility for application of your computer.
If you have any questions about this project feel free to comment on this Instructable or on my website at [http://8-bitspaghetti.com](http://8-bitspaghetti.com/). I wish you the best of luck with this project.
# The Future of the Computing according to Bill
# Remarks by Bill Gates
> Social Ecology Eclectic : Bill Gates .NET
> https://www.zulenet.com/see/BillGatesNET.html
### Forum 2000
### Redmond, Wash., June 22, 2000
**BILL GATES**: Well, it’s exciting to finally be here and have a chance to talk about this next generation of software that we’re building. We had a meeting a couple months ago where we sat down and said, "Okay, what is it that we really want to explain here?" And when I walked into the meeting they had a slide up that said, "We have to explain CSA." And I sat down and I thought, "What does CSA stand for?" And I thought, "Well, I’ll just play along here. It should become clear. You know, I understand what’s going on around here."
And so they were talking and talking and, you know, it wasn’t clear at all. So I thought, "Well, I guess I’ll have to make a fool of myself and ask what CSA is, because it’s clearly this thing we have to explain at this event, so I’d better know what it is." Well, it turns out that CSA stands for **Chief Software Architect.** (Laughter.) And so in a little bit I get to explain how I’ve spent the last six months since I’ve been Chief Software Architect, and with the shipment of Windows 2000 we really have this opportunity to focus our efforts in a new direction and conquer some new horizons.
A lot of what you’re going to hear about today are things that we’ve been working towards for a long time. I’d even go back to vision efforts like the Information At Your Fingertips work that we did back in 1990. There’s a big difference between what we’re talking about today and that vision. The difference is that the underlying technology and the ability to actually make all of those things concrete is now quite clear -- quite clear because of the industry progress over the last few years, quite clear because of the investments we’ve made in basic research over the intervening years. And so what we’re going to be talking about today is something that is very concrete for us, even though it rolls out over a many year period.
First, let me start by talking about how we see the industry framework, what’s really going on.
Well, we’re certainly moving to a digital world. You know, we can see this progress month by month. You know, photos with these great digital cameras, the ability to touch them up, put them in an album, send them around; still a lot to do before that’s 100 percent for the way that photos are done, but we’re getting there.
Music: the ability to have **small devices** that contain literally hundreds or **thousands** of your **songs**, where you can **sequence** them the way you want to. In fact, the main issue about digital music is making sure that people are willing to pay for it, as well as being able to use it.
Video editing has been a tough challenge, because of the size and the speed of the processor required for that application. But with the **next version** of Windows we include that application and you’re starting to see great digital cameras.
**Note taking** is probably one that surprises you to see on the list there. That’s something we’ll be talking about a fair bit today. We’ve always believed that you should have a digital device, a **full-screen device** with you wherever you go, so even in an event like this one it’s our view that you’d have a full-screen digital device, where you’re fully connected and your notes are recognized and searchable, just like all the other material you work with.
In the world of business we talk about how transactions are done over the Internet, but if you really dig into that and say, "Okay, what happens if the product’s going to be late? What happens if you receive what shipped and it actually doesn’t meet the specifications?" Today, that kind of complex business dialogue is not done on a digital basis. It’s only the most straightforward transaction that goes on there.
And so the idea of taking buying and selling and really matching up every buyer with every seller and taking the richness of that relationship, including the customer service and the unexpected events and bringing digital efficiency to that; that’s still a horizon that has not been conquered.
The final point here is thinking about knowledge workers. Their world today is very bifurcated. Yes, the PC has been a wonderful thing in terms of document creation, PowerPoint presentations and spreadsheets, but as they work through their day there’s a lot of paperwork, there’s a lot of **handwritten** notes, there’s a lot of meetings that, you know, are **purely analog**. They can’t go back and take a snippet of that meeting, send it around. They can’t search the meeting to see what happened. If they want to go to a meeting and learn something, they can’t test their knowledge in a digital fashion.
So we have an opportunity to take this vision of a digital world and apply the magic of software to make this a reality.
But it’s not quite like the past where there will be a single device that defines all of this. There will be many different devices. We’ll talk today about the relative role of the small-screen devices and the full-screen devices, but I think you’ll agree there’s a substantial role for both of those, and even some variety within each of those categories.
And so the question of how do you take software to enable across many devices, that’s a challenge we’ve been thinking about for the last few years.
Well, the Internet is the starting point here. The fact that it’s at critical mass in terms of not only having Web sites, but doing business across those Web sites is very exciting. And that is truly a global phenomenon. The simplicity of pointing your browser at a URL, the simplicity of following a link, having a history list, that’s a fantastic thing. And so the Internet is very, very much in the mainstream.
But what is it today? Well, primarily it’s being able to connect up your screen to the presentation material on any different Web site. And so in a certain technical sense it’s a lot like taking a 3270 terminal on a network and simply being able to connect up to many mainframes.
What you see is one site at a time. And that site has to be authored to your particular device, the kind of screen size that you’ve got, the kind of interaction techniques that are available there, the **resolution**. And so we’re connecting things together, but we’re not using the intelligence at either end, and we’re not creating something that takes information from multiple sites.
When you get that page of information today it’s **basically read-only**. In fact, imagine yourself trying to do a product forecast or even saying **you want to buy from many potential sellers**. You have to **manually go to those different sites and either try and cut and paste the information, which doesn’t work very well, or simply write it down on a piece of paper.**And then you move from that world into your productivity applications, like Microsoft Office and you recreate the information there. And that’s where you’re able to compare the data, look at it graphically, and combine it with your own thinking about it. **But that is a different world**. That is not the world of the browser.
**So we’ve got an environment that’s read-only**. It’s an environment where the user isn’t very much in control: the idea that somebody can send you junk mail at any time or when you’re sitting and working on something mail that’s fairly low priority will come in and grab your attention. All the different things that are going on in the Internet, if you want to see if something changed, that’s basically a manual process that you’re spending your time trying to find those things out.
**There are many islands in this world**. If you take your PC at home, your PC at work, it’s a manual operation to try and move your favorites, move your files or any of the other things around between those. If you have a PDA type device, you have to go through **the effort of deciding what subset of the information you want to download**. When you’re connected up over a low-speed link, it’s very complex to control which e-mail or other files or notifications come down onto your device.
So **it’s up to the user to manage these islands**. And when you get into issues like group naming and security across these various islands, it’s clear that the infrastructure is **simply not rich enough**.
Finally, this is an Internet where the keyboard is our primary means of interaction. We’re still typing in commands. Over the last few decades I’m sure you’ve all seen lots and lots of demos of **handwriting, speech recognition, visual type inferences with a camera**, but the question has always been **when is somebody going to build that into a system and create a programming model so that all the applications -- and when I say applications I include all Web sites** in that. It’s a broad definition. When is somebody going to define it so those things can declare what sort of language, what sort of verbs or actions they’re capable of?
So you need a programming model for this natural interface. And having the tools that let you do that and having the rich system, that’s really the starting point for getting away from the keyboard being the only way that we interact.
So in the world where we go beyond browsing you can think of the Internet as more than a presentation network. It truly becomes a full platform, where you have **intelligence on servers**, intelligence on **clients**, working on behalf of the user.
Now what does that mean? That means that when you want to see information, if you’re planning a new product, **your device can go out to many different Web sites and extract exactly the information that’s interesting to you. And if we do it right, it can bring it into the view that you’re using to do your creativity, so that it’s not just a read only screen you’ve got there, it is the full power of the device allowing you to do your work**.
When we think about knowledge workers, they’re not paid simply to click through screens and read what’s there; their **value added** is taking that information and synthesizing it. And so by bringing those two worlds together, the world of reading, writing and annotation, we can allow them to do their job in a different way.
Now, when we think about multiple sites and customizing the information and combining it in the right way, obviously we’re using a protocol that goes beyond HTML. HTML is defined purely for presentation. As you’re going to hear today, **XML is the base protocol for this new era. It is the thing that will be exchanged between sites, between sites and clients in order to build up these new capabilities**.
**We are saying that the natural interface richness will be built into this platform, and that’s really putting a stake in the ground, because we’re going to go out to developers and say, "Here’s how you write your applications, so that handwriting and speech can interact naturally with that application."**
We’re also saying that the **islands** that we’ve got out there, certainly those can be broken down. The way to break it down is by putting out services that work across all the different devices, moving the information around, keeping track of which information is important and working on behalf of the user.
**So that’s the new concept, the concept of something running out in the Internet, out in the clouds, working on your behalf.**
Well, XML is something that actually grew out of a document format called SGML, but it’s really transformed itself into an essential way of exchanging heterogeneous data. And I’m not saying that the work around XML is done. In fact, you might say that it’s just at the beginning, because for every real world object, whether it’s a healthcare record, a banking record, a supply chain dialogue, around every one of those things we need rich standards. And we need very rich software tools that can map between different schemas, data layouts, map between one version of a schema and another version of a schema. So the very platform itself has to embrace XML in a very deep way.
It’s exciting the progress that’s taking place around XML just even in the last six months. We’ve got here a standard that Microsoft is very much behind, but not just Microsoft. We’ve got IBM and many others joining in in things like the **SOAP** definition that explain how XML can essentially be **used as a program to program protocol, how programs can exchange arbitrary data with each other.**
And that’s why we talk about the Web as a platform. You know, using XML, the idea that you go to many different sites and pull that information together using the intelligence of the device that becomes a reality.
And so it’s really around those rich scenarios that all this work on XML is going on.
**XML will transform productivity tools. For example, the spreadsheet will be changed by XML. The database will be changed by XML. The programming languages themselves will be changed. In fact, there will be language innovation in every popular programming language around XML. So it’s a very profound change, even more profound than the change HTML brought to the world of presentation.**
So what is Microsoft doing to help move this new world forward? One of the other questions that we had up in that meeting where they asked me to explain what CSA was, was that I had to explain why we spend billions and billions of dollars on R&D, and what was it, what were the big things that we’re coming out about.
**Well, this idea that we need a new platform, a platform that takes as its center the Internet and the user and then takes the devices and services those rather than having the devices at the center; that idea’s been emerging for a long time.** And the question is what can be done to get enough of those pieces together to really get that to critical mass.
Well, Microsoft is announcing today that our efforts as a company are going to be focused around this next generation platform. We call it **.NET**. That’s a term you’ll hear a lot today, and it encompasses more than one thinks. It encompasses the idea of putting rich code onto every one of these clients. It encompasses the idea of having services across the Internet that help every one of these clients. And then there’s a new generation of servers that can work together providing those services that can either run inside of corporations, can run inside an ASP or can be run by the software creators themselves in order to allow all the users to get at that service capability.
There are some breakthrough elements that are necessary for this world. The user interface, which we’re talking about now, as the user experience, will be a lot richer in this environment.
In order for this to become popular, it’s going to have to really put the **user back in control**. It’s going to have to deal with their concerns about too many notifications, too much junk mail. It’s going to have to deal with their concerns about being interrupted by things that are **not relevant** to them. And perhaps more importantly it’s going to have to help them feel that their **privacy is preserved**. And this idea that you’ve got all your information essentially out in the cloud and as soon as you authenticate yourself onto these difference devices, that clearly raises the issue of whether the architecture at the very core is designed so that you’re the only one who controls that information. And that’s been a key point of discussion amongst the people exactly how we define these schemas, how do we define the protocols and user interfaces so that privacy and security are integrated in here.
Throughout all those futuristic demos you’ve seen over the last few decades, there was always this concept of an agent, something working on your behalf. It wasn’t just going to individual Web sites. The agent knew what you were interested in and it would, based on a set of rules or implicit things that it had learned by watching you do your work, it would work on your behalf. That concept, that actually goes back to 1945, is a very powerful concept.
Well, we now have what it takes to really build an information agent. We have XML as an interchange standard. We have rich decision software called**Bayesian Inference Software that we can build down into the system** that can track your usage and adjusting in an automatic fashion.
.NET is a very broad thing. There is code in **Windows**. There’s code up on the **Internet**. There’s code running in all the different **devices** that connect up here that implement access to the .NET capabilities. There’s quite a spectrum of capabilities there. You can actually get at these services with a device that doesn’t have anything special. If you simply have a **browser**, you can connect up and get to the .NET services. But it’s far richer if you have a device that actually has the .NET code down on it.
**my storage, notification and identity**
**my building blocks**
**.NET**
**XML**
So what does it look like diagrammatically? Well, you have the XML standards, then you have .NET infrastructure and then people have building blocks that sit on top of that, building blocks for things like storage, notification and identity. And every Web site can choose optionally to participate in this by offering up notifications. So if information changes that they think their user might be interested in, it doesn’t just directly go in the form of emails to the user, rather it goes to the information agent that’s working on behalf of that user to decide what are they doing right now, what device are they using, what priorities do they assign to information from this site that’s categorized in this way, and do exactly the right thing on behalf of that user.
There’s a very strong analogy here between what we’re doing now and what we did with Windows. And that is, you know, what we’re announcing today is more analogous to the announcement of Windows than it is to our Internet Strategy Day back in 1995. Back in 1995 we were talking about taking the world of Windows and the world of browsing and making sure that those two things worked together, making sure the Internet was going to be accessible to a lot of people. And that was a very straightforward set of steps over an 18-month period that we did to make that come true.
What we’re talking about today is far more ambitious than that. This is a new platform. This will affect every piece of application code that gets written. This will redefine the user interface, what you see on the screen and how you interact, as much as the transition from DOS to Windows did. And so there’s no Microsoft product that isn’t touched by this activity.
If you look at the capabilities that are in .NET, for almost all of them there’s an analogy in terms of what was in the operating system that we provided with Windows. For example, take storage. We’ve always had a file system. That’s something that applications have used pervasively. If one application saves something out, it’s available to the other applications.
**Now that storage system was working only on the PC. And the storage system wasn’t very rich. If you wanted to index those things or search them in a rich fashion, you needed to go off and use something more powerful like a specialized or general-purpose database to do that**. But the idea that you had storage and all the applications could count on that storage that was part of the Windows platform.
The .NET platform has storage in a very analogous fashion. However, that storage is out in the cloud; it’s not on any particular device. But the .NET platform is incredibly intelligent about replicating that storage as appropriate onto the different devices. It understands when you’re connected up over a high-speed link. It understands the relevance of certain types of data, depending on which device you’re using and what context you’re operating in. It’s also a store that’s richer in the sense that the way it indexes things, the way you can search those things is more powerful. And it’s actually based on database technologies. So this is what we call the XML Store, which is one element of this overall platform.
Also think in Windows about the clipboard, the fact that you could exchange information between various applications. That was a key advance that was not available in the DOS environment. Well, on the Internet today that idea of assembling information from different sources and being able to share it in that productivity world, that’s a very manual operation. So here we have the idea of using XML, of gathering up the data, and integrating it together in a seamless way.
One of the big advances in the Windows environment over the years was the idea of that compound document, you know, object linking and embedding and all the infrastructure that came along with that. That’s when Windows started to really become object oriented, as we got different types of embedding and we supported all the rich operations that third-party applications would bring in with those embeddings.
### **Well, here we have the idea of the XML data in a universal canvas. This universal canvas is the idea that you no longer leave the browser. The browser, you’re always in the browser, even when you’re doing your creativity work. And so we’ve talked about that as the universal canvas, and you’ll actually see our universal canvas technology being demonstrated for the first time as part of the presentation today.**
So for every element of Windows -- user interface, the APIs, the hardware drivers that allowed it to work with all the different capabilities people plugged into the PC -- for each one of those things there’s an analogy here. But it’s an analogy across all the different devices, and that includes the things that go on in the clouds.
The key principle that this becomes successful by getting lots and lots, I mean literally tens of thousands of applications that are written to it, that principle is absolutely identical. And so it’s by creating those opportunities and letting applications move up to a new level that this dot-net platform will be successful.
What are these building blocks? I’ve already talked about the XML store, which is a very central one. Identity will evolve out of the service we have today called Passport. Notification is this idea of all the different websites tracking things that you might be interested in and delivering them to your agents. **Calendar, not just individual calendar, but shared across many different people**; the ability to look things up, the ability to have your software always kept up to date, those are examples of services that are completely programmable. And so just like we did with Windows we’ll have development kits in our tools that let people write applications, taking advantage of these services.
We ourselves will, of course, build applications on top of these things, but as a percentage of what gets built, that will be a fairly small portion.
I want to talk about the new user experience. When we broke down the technology breakthroughs that were critical to .NET, we formed **eight different groups inside the company**. And each of them went off and spent several months working with the leading people in that area to decide exactly what our architecture would look like.
The team that I chose to lead was the one defining the user experience, and we had people from **Windows and Office and Research** and people with all sorts of different views on exactly where the user interface should go.
One of the fantastic things when you step back and think about user interface is that when you have essentially a clean sheet of paper, you can do a very rich job of taking all the things that over the last really ten years, where the user interface has simply been evolving and new things have been added to it, you can anything that’s duplicative or that’s proven to be, you know, that there should be just one simple way to do things and clean all of that up.
## **So having the new user interface is really a fantastic thing, but you’ve got to start at a much higher level to justify doing that; in this case, just by starting with the browser, starting by making it communication-centric, defining it in such a way that all these natural interface technologies can work with the applications that are written to this new user interface.**
This user interface in a sense has to be more abstract, because the different screen sizes that we’re working across here is incredibly broad. And the world of the PC in any particular year we could tell you the screen resolution we were targeting: **640x200, then 640x480, then 1024x768**. You know, there was a clear target in mind there.
### **Well, now when you’re going to have pagers and screen phones and TVs and something in the car, as well as the full-screen PC device, where even there the variety will get greater than it is today because you’ll not only have the tablet form factor but there will be people who have an LCD that’s literally the size of their desktop so that they get as much information viewing as possible. So we need to abstract out the idea of how do you use that display surface.**
### **We also need to make customization something that’s much more built in to the environment. We also need to take the idea that the world of files and e-mail and data, all those were really quite disparate and the commands you use to navigate those things and work with those things were really very separate. And if you look at the current user interface and say, "How many search commands do you have in your PC", the answer would be literally dozens and dozens. And sometimes it’s not even clear which one to use and the dialog that comes up is very different there. So there’s a lot that can be done in the user experience.**
The idea of accessing the information anywhere through that store has to be defined; the idea that you can work offline and the information will be replicated down based on knowing what kind of things you want to do while you’re offline, without your having to get explicitly involved to think, "Okay, I’ll download this code, this file, this e-mail," all the different kinds of information that today you explicitly have to do manual work on.
Part of this is to create the creativity Web, the Web that is not just reading. And you’ll find that the idea of annotation, whether it’s text annotation, voice annotation, handwriting annotation, that’s a fundamental capability across documents and Web sites. Your ability to create and view those annotations, this user experience file guide will define exactly what those things look like.
And so whether you’re using it from the keyboard or from one of the new natural interfaces, the appearance of these applications will be quite different than the applications we have today.
I wanted to give you a little sense of this by showing you some of the elements that go into it, and, of course, a demo is the best way to really get a feel for this. So I’d like to ask Jeff Rainier to come out and show us a few examples of the natural interface element.
**JEFF RAINIER**: Thanks, Bill. Today I’ll tell you about two of the .NET user interface elements: **Smart Tags** and **the type-in line**.
Now, everybody knows that computers are really good at many things, but that there are some simple things they just don’t do very well. For example, if I type June 23rd, a computer might not know that that’s a date, or if I type 2:00 P.M., it might not know that that’s a time. And even if it did know those two things, it wouldn’t necessarily know that times and dates are useful for things like scheduling meetings.
But the .NET platform will know things like this. In fact, it will **automatically recognize and categorize important words and phrases while you type them and it will turn them into smart tags. Company names, people names, times, dates, a multitude of other things will all automatically be smart tagged while you type**.
Let me show you how this is going to work using some real live running code. Imagine that I’ve gotten a mail message that asks me to write a report. I’d probably start by gathering the data that I needed for the report. Now, today that would mean remembering which database the information I needed was in, knowing how to use that database software and probably transferring some information into a spreadsheet to do some analysis.
But the .NET UI will make this much, much easier. It will eliminate many of those steps.
Let me show you how.
Look carefully at this mail message, and in particular at Astro Mountain Bike Company here. You see that dotted blue underline? .NET has placed that there, because it **automatically realized** that Astro Mountain Bike Company was a company name and turned it into a smart tag. As a result, if I move my mouse over top of it a **button will appear**. And if I click that button a menu is revealed. On this **menu** are a number of actions that are **pertinent to Astro** because it’s a company name. So from here I can go to their home page, I can look at a financial report on investor about the company or I can analyze their sales data. Let me do that.
You’ve seen how smart tags work in mail messages, but they’re everywhere in the .NET platform, and they work pretty much the same way. Smart tags can also be personalized. This way users are able to specify what words should be smart tags, what categories they should fall into and what actions appear on that menu that you just saw.
Here in this spreadsheet mountain bike models have been smart tagged, so I can click on something like the MB3000 and get some more information about it. In this case, I can go out to my corporate intranet and look at information about this model.
But now let me show you .NET in action, recognizing smart tags.
I’ll switch to a **word processor** and do a little bit of typing now. You can watch for that **dotted blue underline to appear**. That will mean that -- there it is. Hanson Brothers has been **recognized as a smart tag** and a company name, in particular. So just like before I can get **actions from this menu.**
Now, one of the actions that’s worth pointing out is that **I can go from here to Hanson Brothers’ home page, but remember I never typed a URL or added a hyperlink**. This is possible because .NET noticed that companies often have home pages and knows how to get from the name of a company out to that company’s homepage.
**Now that I’m on Hanson Brothers’ home page, you can see that there’s the dotted blue underline here under this mountain bike, under the name of the company again, and even under people’s names.**That shows that smart tags work on the web as well, and they work basically the same way, the same menu, the same button and the same list of options.
But now let me shift gears and tell you about another .NET innovation.
The .NET user interface is powerful and more natural than past user interfaces. This natural interface is based on emerging technologies like **speech recognition, natural language processing and handwriting recognition**.
And one central feature of this user interface is something called the **type-in line**. It’s right here. Now, from this place you can do a number of simple things like issue commands, open documents, search the web, but the real power of this interface applies beyond that sort of simple commanding. That’s because dot-net is able to answer the questions that you asked and it’s able to answer them in natural language and if you’d like it will even speak the answers to you.
Let me show you how this works. (Typing.)
> **COMPUTER VOICE**: Which index would you like?
>
> **JEFF RAINIER**: (Typing.) Okay. Checking for the latest updates on that index.
>
> **COMPUTER VOICE**: As of 9:10 A.M. the Dow industrial average is down minus 64 at 10,433.74.
>
> **JEFF RAINIER**: Did you see how the computer asked me questions to resolve ambiguity and kind of worked with me like a person might have? That’s the sort of power and intelligence that’s built into the .NET platform.
>
> Let me show you one more example. (Typing.)
>
> **COMPUTER VOICE**: How long do you want to meet? (Typing.) Where do you want to meet? (Typing.) Do you need to check my schedule? (Typing.)
>
> **JEFF RAINIER**: Ooh, I think my typo there caused some problems. Let me try that one more time.
>
> **COMPUTER VOICE**: What would you like to do now? (Typing.) How long do you want to meet?
>
> **JEFF RAINIER**: Okay, this is looking more promising. (Typing.)
>
> **COMPUTER VOICE**: Where do you want to meet? (Typing.) Let me see if you are both available at this time. Okay, I’ve scheduled an appointment with Mark Leimberg on Friday, June 23rd at 2:00 P.M. for 30 minutes in his office.
>
> **JEFF RAINIER**: Okay, you’ve seen how this interface works with typing, but this is much more natural and easier to use if you speak to your computer.
>
> Imagine for a second using your cell phone to call in and get high priority mail messages, maybe make dinner reservations or even check for the latest news, all from your .NET server.
>
> So I’ve shown you two elements of the .NET user interface today, all of which are available with typed input, spoken input and handwritten input.
>
> I’ve shown you smart tags, which automatically recognize and categorize words and phrases and let you act on them.
>
> And also the type-in line, which is just an example of the natural user interface, a centralized place for issuing commands, asking questions and working with your computer.
>
> There are many more innovations in the pipeline. This is just a sample.
>
> Thank you.
>
> **BILL GATES**: Thanks, Jeff. That was great.
Obviously, natural language understanding is a very key element, and particularly the idea of allowing third-party applications to come in and declare exactly how they want to interact with the different utterances that are made through speech or through that type-in line. And so it’s an **API** that is very, very critical.
Well, let me move forward with our .NET work. We’re making some very exciting **automatically assumptions** about what our partners, who do hardware breakthroughs, will be doing in parallel. We’re not assuming that the PC or the Internet network capabilities will be standing still. And, in fact, we are **automatically dependent** on a lot of these **automatically breakthroughs**. We’re assuming that **automatically broadband** becomes more pervasive. Broadband, of course, today is very prevalent in business-to-business connectivity, but it’s going to take time for that to roll out to consumers, particularly on a worldwide basis.
But some of the advanced capabilities here, where we use **video** **streaming**, we have **digital meetings**, some of those are there to both take advantage of and depend on those **broadband** advances.
We’re also very bullish on wireless, and you need to break wireless down into several different categories. We’ve got wireless in the workplace. The buildings at Microsoft now are wired up so that we can carry our PCs around with us as we go to meetings or simply move around during the day and we’re connect up at about 11 megabits wherever we go. And that kind of flexibility is very inexpensive, and I think it will be very typical for a workplace to have that.
**In the home there are some new standards emerging that are going to make very high-speech home wireless networking quite inexpensive. And the ability to distribute not only, you know, photos onto a simple LCD on the refrigerator or anywhere in the house, but the ability to distribute your music, the ability even to take the PC that might be in one room and distribute out that user interface to any of those screens, that will be possible over this kind of wireless network.**
Now, what that means is that your photos can all be in one place, your applications can all be in one place, and yet be available on a pervasive basis.
And those wireless networks will not have per minute charges. They’ll simply be set up and you can use them as much as you want.
Now there will be wireless data in the wide area network. All the excitement there, you know, the valuations, the investments relate to the idea of moving beyond a pure voice market to a data market. Now, that data market will evolve both small-screen and full-screen devices. The small-screen devices are incredibly handy in terms of looking at a map, looking at your schedule, getting high priority messages, but it’s the full screen device you’ll use as you’re creating documents and really browsing through rich information. So we need to make sure both of those are connected up to this wireless environment.
**We’re very bullish on the idea that over the next few years this wireless data capability will become pervasive as the third-generation wireless infrastructure is rolled out.**
We think that authentication advances will be very important to this. Passwords are the weak link today in security systems, and so pervasive use of smart cards, in some cases complemented by biometric identification, is a really necessary element to make this all work.
You know, if people understood what a weak link a password is, I think they’d worry a lot about putting more and more information into this environment.
So really knowing who the user is is a very critical element to get established. Fortunately, the cost of those smart cards, the idea of having them standard in a keyboard reader, that’s something that I think with our efforts and those of our partners is certain to take place.
**The PC that we’re thinking about is obviously much more powerful than what we have today. The microphone will be a built-in capability, and so a lot of the communications that you do will be real-time in nature. The idea of connecting up to somebody, editing a document together, that will just be common sense. People will wonder why it wasn’t easy to do that before.**
The camera won’t be on every PC, but a high percentage will have it. And so that’s an aspect of natural interface that the platform will support.
And PCs will have a new form factor like the tablet, but in general it will be a lot smaller and a lot more convenient. Even that kind of desktop LCD will be a PC form factor.
The small screen devices are also something where there will be incredible innovation. In many ways the power of that small screen device is greater than the power we have in the PC when we introduced Windows ten years ago. So the kind of capabilities, whether it’s book reading, playing your music, dealing with photos, the kind of media richness and agent type smarts that can be down even on the small device, working on your behalf, I think they’re really going to surprise people.
So let’s take a quick look at what we’re seeing in terms of these **next generation devices**. And to kick that off I’d like to ask Brian Shafer to come out and talk to us about what’s a phone going to look like.
**BRIAN SHAFER**: Good morning, Bill. Well, good morning. Well, we all love these myriad new devices that are coming into our lives, especially cell phones, but they all share one **weakness**. They tend to be **islands** of technology, especially those cell phones. Sure, they might synchronize in some rudimentary way with a PC, sharing phone numbers and the like, but they don’t fully **interoperate** as well as they could with each other or with other platforms.
The .NET environment gives us the ability to address some of these issues.
Now what I’m holding here is a new class of device, a .NET device, if you will. Now, specifically this is a **smart phone** that we’re working on with our partner **Samsung** and we’ll be bringing it to market sometime next year.
These devices bridge the wireless telephony world that we all know and love with powerful computing, allowing us to actually extend the .NET environment down into a small portable device such as this one.
**So let’s take a look at what I’m talking about.**
Now here you can see I have a new **smart phone**. Now, in this particular case, this particular phone has never been used. It has no data on it. And it’s not been personalized in any particular way. And so since it’s the **first time use**, what I’m going to actually do is log onto this device using the Passport system to give me access to the .NET environment.
**Now when I log on, a lot of things are going to happen. First, all the relevant information from my personal area on the .NET server is coming down to the device, all those phone numbers, my schedules, my appointments, et cetera, even my e-mail coming down to the device. I’m also getting my personalized information being sent down as well.**
So there you can see we’re now up and running. So the next time I turn on this phone, this is where I’ll be, everything off and running for me. I’ll have my contacts and appointments there. And as you can see, it’s a **personalized view**. So this could just as easily be instant messaging contacts or colleagues who are up and running at the moment, or perhaps some of my corporate e-mail or what have you.
Now, to be clear, I’m not just browsing at some Web site at the moment. The .NET network has actually sent down all of my information to this naked phone wirelessly based on my preferences. So no matter whether I’m **online or offline** I have immediate access to my information my way.
**And since this is a real computer**, from here I can actually control or respond to a .NET application. And you’ll see some examples of that as we move forward in our presentations today.
Now, most importantly though this is a platform so our partners and our customers will be able to develop .NET or native applications for a phone such as this one.
So let’s take a look at some of those native applications that are available to me. As you can see I have some powerful PIM functionality: calendar, contacts, my inbox, tasks, notes, et cetera. What I effectively have is **wireless outlook** available to me at any time. You’ll also see that we also **include Internet Explorer** on these devices. So in a traditional sense I could go and wirelessly look at HTML or WAP-based data. But **most importantly**, however, smart phones and their cousins, the Pocket PCs, **their browsers will support XML, making sure that they are full-blown participants in .NET services moving forward**.
Now, I mentioned that this phone is able to interact with other devices in the .NET world, so let’s go ahead and set up an example of that. I’m going to go into my calendar and pull up a **new appointment**. I’ll set an appointment for lunch with Bill, say, next Monday. I’m going to pick the Pebble Beach Café. Now, you’ll notice my preference for all the locations where I book meetings are automatically in my phone, so I don’t have to sit there and type them all in three characters every number. So I’ll go ahead and set the date.
**And now what’s happening is the phone has sensed that an appointment has changed, so it’s updating the .NET server. And since I’m wireless, it doesn’t matter where I am, this happens. The .NET server then takes that information and automatically federates it amongst all my other devices -- and not just my devices. More specifically my colleague’s Pocket PC, a wireless Pocket PC is also updated with this appointment. Or if we switch over to my assistant’s PC, you can see that this appointment will now come in and be synchronized all by the server, meanwhile while I’m out running around doing my job.**
So as you can see the combination of .NET services and these smart devices helps bring to life our vision of your information anywhere, anytime on any device.
**BILL GATES**: Thanks, Brian. Super.
Now let’s turn and look at the **full-screen device, in particular this tablet form factor**. I’d like to ask Burt Keylie to talk to us about the work his group is doing in this area.
**BURT KEYLIE**: Hi, Bill. Thanks.
So .NET services are going to help information flow to all sorts of devices, and the smart phone, Microsoft smart phone software, in particular, is going to really enable a whole class. But there’s another class of device that we think is going to be wildly popular, and this is the device that combines the **visual qualities of a magazine with the handiness of a paper notebook and all the power of a PC.**
So what we’re going to get to talk about today and show today actually is the actual first demonstration of what Microsoft calls our vision for the **Tablet PC**. Okay, can you see this display?
And within the next year or two you’re going to see Microsoft’s partners bringing out hardware like this. This is actually prototype hardware running real software, including real Windows 2000.
So one thing about a Tablet PC is -- we’ve looked at electronic books and you’ve probably heard a lot about electronic books lately. They’re a type of content that really demands a better device. And I want to zoom in on this. First of all I’ll show you that turning pages on this device is really as simple as turning pages in a book. So we have nothing but a book page here, and the way we turn pages is nice and very simple.
I want to zoom in. I want to show you something about the software. And this is what we call **ClearType**. When we talk about having **the quality of paper**, can you believe how paper-like those fonts were?
I’ll zoom back out a little bit.
Now, the way we see it, devices, all device attempts in this class have failed to recognize the need to match paper, and so we’re going to show some things here today that are .NET UI constructs that **actually match the interactivity of paper**.
So this is an electronic book, and I can read along and see a character. Here’s "Baker", a character that’s introduced at this point. In order to highlight that, remind myself of when the character was introduced, it’s simply a matter of highlighting, tapping and it’s done. I can place a bookmark just as simply. Oh, and **I can look up a word in as simple a manner as tap on the word, tap on lookup, I see definitions for "stretched", "stretching", et cetera. A third tap and I’m back reading with no visual artifacts, no clutter.**
So these are the kinds of qualities of paper that we really think that a tablet PC should be able to have.
Now, one of my colleagues is a fellow named Chuck Zacker, and he’s also obsessed with this Tablet PC idea. And his obsession goes all the way back to the mid-70s when at Xerox PARC he worked with a fellow named Alan Kay, and they worked on a Dynabook concept. Chuck is on our team and he suggested to me I really ought to have **a subscription to Slate Magazine**. And it gives me an opportunity to show you some .NET services that support this paper-like experience.
So as I’m reading I can go to a bookstore. And look, this is integrated browsing, integrated in a way that **doesn’t show me stock quotes and e-mail messages and banner ads** and all these other news feeds and things. I asked to see book sites and so I get a **list of sites** that can provide **titles to the Microsoft Reader**.
So one of those sites is the Slate subscription site. I can say, **"Yes, go ahead and download Slate", and I get a message, the download is complete and it’s in my library.** So I’ll just go over to my library and take a look and here it is. It showed up as the last one acquired.
Now, how do we make a book buying purchase so simple? Well, there are a few .NET services behind this, one of which, of course, is the integrated browsing.
But the second is **Passport**, which manages all of the transaction aspects, so that the purchase can be as simple as tapping and then watching the download occur.
The third thing is a new service called a **digital asset service**, which actually does **digital rights management for me**. In fact, it’s **individualizing a personalized copy of this book and downloading it into my library, and it actually has my name on the title page of the book. I know it’s mine. I know it’s authentic and I know I can read it on any of my devices.**
So now reading books is not all we want to be able to do on a Tablet PC, right? Of course, we’re going to want to check our e-mail. And to do that, we’re going to want to use real **Outlook**. Well, at least some of us are. So here’s a message from Butler Lampson. He says he’s got an attachment. I need to be able to open attachments, don’t I?
So open this message, open the attachment and it’s a document. I recognize it. It’s Charlton’s interactive paper document. It’s very nice and concise. But I would like to make some comments here. I think that if he could use .NET more in his discussion, he’d be following the corporate theme a lot better.
So now do I have to actually go get a keyboard in order to make comments on this document? I shouldn’t have to. I should be able to simply make marks on the page. So one of the .NET services we’re talking about here is the retrieval. So we’re talking about i-paper as a brand. We probably could do better than **i-paper**. We’re talking about **.NET UI** constructs here.
**So I just want to be able to mark with my pen, put a little margin note, and I’ve done my markup. It’s simple.**
Now, one thing else I’d really like to be able to do, and I’d love to be able to do this with paper is just insert some space and write a little bit more. **"Corporate tie-in". Did you notice that when I inserted the space, the annotations hung together? That was because they’re smart enough to move as the underlying document changes.** So when we can do things like, I can be sure that when Butler receives this back it will all make good sense. So that’s a great way of using ink in a way that works much more like paper.
Now, something that I haven’t been able to show you yet is the way that ink can be interactive. So to do that let’s pretend that I’m in the audience and I’ve taken these handwritten notes about Forum 2000. And I’ve done a few sketches. And I want to be able to work with these notes. For example, I really thought that that smart phone was cool. I ought to be able to just select ink like I would text and highlight it. I can do that with handwritten ink and a tablet PC. I could apply bold, italicized, underlined, et cetera. There’s all sorts of things we can do with handwritten ink. In fact, if I want to take a look at my notes in a much broader way I can switch my paper to college rule and see all of that ink shrink down and re-flow just as if it were text.
So I’ll zoom back in to give you a little bit better look. And it’s very easy to manipulate drawings with a pen. So we’ve got the tablet into the picture here. We’re starting to develop a story, and I want to check and see whether the theme of .NET is coming together well. So to do that I’d like to be able to take the word ".NET" and just search for instances in my story. So let’s see what we find.
Now, do you see what’s going on here? It’s searching my handwritten ink and recognizing where I’ve used those words, even though we haven’t converted my view to text. That’s because handwriting recognition is going on in the background.
So we work with my ink and we see lots of instances of .NET. It looks like it’s coming together pretty well.
So one last thing, of course, I’ve got to have a headline for my story. And so I’ve got a few attempted headlines here. I’m not very good at this. If I want to see these headlines as text, it should be just as simple as saying, "Recognize that" and see them as text. Now, that’s because the handwriting recognition can go in the background, but it doesn’t need to get in the way of using the system, of using the handwritten ink. Only when you want to see the recognized text do you need to do that.
Okay, so that’s a quick view of the kinds of things we see a tablet PC doing and I hope you all are as excited about having one of these as I am.
**BILL GATES**: Great. Stay tuned. Thanks, Brian.
Well, I’m certainly excited about getting one of those devices. There’s really an amazing amount we’ll be able to do with note-taking and sharing information and the whole structure of a meeting and the way that you have handouts in meetings and you never know, you know, whether to keep those around or if you want to change something and share that with other people in meetings.
So both note-taking and the process of meetings will be brought into a digital world and we’ll have breakthrough software that’s part of Microsoft Office that deals with those scenarios, which are completely new to the world of the PC.
**A key point there is that was a full powered PC. That was not just a companion-limited device. That was a Windows 2000 device that ran all the existing applications and the new ones that take advantage of that platform.**
Well, I’ve talked about **.NET being in three different places**. We’ve seen some examples of .NET software running on the **client**, running on the **phone** type device and the **new form factor PC**.
We’ve also talked a lot about these services and you’re going to see quite a few of those today.
**But there’s a third tier here, which is the server**. Today’s server essentially exists in isolation. When you want to go set a server up, when you want to monitor a server, it is essentially off by itself.
But the new vision here in .NET is that those services fit into **the three-tier environment**, and so you can choose to run on these **servers**, which you may have **inside** your corporation or you may have out in an **ASP**. You can run the rich capabilities that we’re talking about here.
So you can host the e-mail there if you choose to. You’d certainly typically in a corporation host your own documents, your rich, you know, creativity things in the company itself. Both for security reasons and just communications bandwidth and control type reasons that makes sense. **And yet you’d want that server working in conjunction with the cloud-based services in order to make some of those documents available, assuming the right security things had been set up.**
So we need symmetry between the three different levels. We need to **define the semantics of security and events and mail activities and workflow around one architecture**.
Another key point that we won’t dive into in much detail today is that these individual servers need to have incredible scale capabilities, and all the abilities, not just scalability, reliability and manageability as well. That’s something that Microsoft has been pouring a lot of R&D focus into, and we’ve made incredible progress, as we announced with the world-setting benchmarks around Windows 2000.
The key concept is to use software to allow the **individual server building blocks to be combined together**. And that’s really a breakthrough for both reliability and scale.
And so that means that even in this .NET world, as the level of transactions is ten times greater than it’s ever been before, the servers behind the scenes will be responding to that and able to handle that kind of load.
You want to be able to mix and match these servers we’re talking about, the file servers, mail servers, database servers and with the things that you decide to just do through an ASP or through the standard .NET capabilities. And there are special things we have to do to make sure that these servers are defined for ASPs, the idea of hosting many corporate customers on a single server, the idea of taking a single corporate customer and automatically spreading their load across many servers.
Now there’s a level of management capabilities there that really pushes the state-of-the-art, goes beyond what people have needed in mainframes and other systems in the past, and we need to make sure that we’re pushing those horizons in the Windows environment ourselves to respond to the .NET server opportunity.
Here’s a quick roadmap. Steve Ballmer is going to go through this at more length a little bit in his presentation at the end the day. So let me just summarize real quickly. **There are some key elements of .NET that are actually here today, things like Passport, the XML work we’re doing. The products we ship this year, what we call the 2000-generation of products, SQL 2000, Exchange 2000, BizTalk 2000, every one of those was designed around this belief that XML is very core.** And it had a profound effect on every one of those designs. So there are things like that that are very here and now.
Next year a key release for us will be **Windows .NET version 1**. It’s not the 100 percent implementation. For example, the full net user experience comes in a major release that will be at least two years off, because of the ambition that’s in there.
**Visual Studio 7** that we’ll be previewing this year has many key elements of the .NET platform.
So next year you’ll see many of the services emerge, but it will be more than two years before all the different services are out there.
And in Microsoft itself in terms of branded experiences, we have a number that will come out next year. And then the full set of services, including things like Office and Visual Studio are in the future timeframe.
So this plan is not about something that all is finished here and now, this is about how we’re focusing the R&D efforts of the company and doing something that literally is as profound as the initial graphics interface work that we did quite some time ago.
So let me **recap** the different levels. There’s been .NET services. And here the real software breakthrough work is in things like the **information agent**, the ability to **get the information wherever you go**. There’s a **you schema** that lets you keep **track of what you think about music and books**, and organizes things in a much richer way than has ever been done before.
**Supporting offline we think is critical**. Even though the Internet and all these wireless things are going to be out there, there are many cases that you’re going to want to be offline, you’re going to want to be able to work at length that either paying those per minute charges or without having to assume that the network is there.
The user experience, there’s a lot of new elements that come into this. In some ways this is -- from the consumer’s point of view this is the most profound thing about .NET, the fact that we really for the **first time have a platform that is designed around a natural interface**, that we move away from the dichotomy of the productivity software and the browser being in two different worlds and instead move into a world that really is the best of both, and partly because we’ve been able to do this as a new piece of work takes everything we’ve learned about user interface in the last 10 years and pulls that together. You know things like when you see a table of information, there are today dozens and dozens of ways that you manipulate that table and you filter that table and in some ways there’s more variety there than even in the search command I brought up as an earlier example. So coalescing that so that whenever you see a table, whether it’s print or font, any type of information that’s done a standard way, that’s part of the style guide that goes with this new user experience.
The richness of the device is working on behalf of the user. It’s not just the performance we need for natural interface, which, of course, is significant, but also things like looking at those **smart tags**, recognizing in the background exactly what actions you might want to take against any kind of information that’s up there on the screen.
The world of programming, there’s a lot of neat new things here, including the idea of the code being updated automatically. You know, the things that make the rich client complicated, those go away here, because the code and the state that you’ve had to manage on the PC yourself, now the .NET services are taking over that capability.**The idea that you can write a simple application and just have that be hosted and available to everyone, that’s really one of the founding principles of the programming platform that’s created here.**
The .NET devices, the new ones will be very, very important. I’d go as far as saying that the market for these small screen and other devices really can’t explode until you have things like the .NET services. **And in the same way that the PC really required one platform that allowed software developers to assume that that platform would be consistent and on millions and millions of devices, users expect the same thing in terms of applications in this new era and the fact that they won’t be stuck with manually dealing with all this information.**
So we think that by working with these device makers and making sure the software platform connect up to those things, we can take and accelerate the market for this variety of devices.
There are many of these categories, like the **TV**the space where we’ve been a real leader in pushing forward what can be done there and how to redefine that experience. And we went to be involved in making sure the software connects up to all these things. This is where standards like **universal plug and play** can make a very big difference.
So what it comes down to is that after 25 years, Microsoft is still focused on the thing that it loves and knows well, and that is building software platforms. This is an era where what’s required of that software platform is far more ambitious than anything we’ve done in the past. And that’s why I’m very glad that we’ve made fundamental investments in our research group. In fact, almost every one of these new capabilities I’m talking about benefits from work that took many, many years and was off in that research environment being pulled together without a particular schedule in mind, but knowing that those capabilities would be very, very important.
So it’s very fitting that in our 25th year as we’ve always had an idea of making these tools for more powerful, that we’re attacking a new horizon, a horizon that will take even what the Internet is today and make that seem like something quite limited compared to what’s possible here.
So we’re very excited about it. You could say it’s a bet-the-company thing. We are putting our resources behind .NET because we believe in this and so our entire strategy is defined around this platform. We are working with a lot of partners. We’re very excited with the reaction they’ve had as we’ve gone through this new strategy. So let me just close by having a video from one of our key partners, Compaq, and their reaction to the work we’re doing here. Thank you
(Applause.)
发表评论