数据流体系结构风格4(骄阳书苑)

上传人:M****1 文档编号:571721154 上传时间:2024-08-12 格式:PPT 页数:50 大小:2MB
返回 下载 相关 举报
数据流体系结构风格4(骄阳书苑)_第1页
第1页 / 共50页
数据流体系结构风格4(骄阳书苑)_第2页
第2页 / 共50页
数据流体系结构风格4(骄阳书苑)_第3页
第3页 / 共50页
数据流体系结构风格4(骄阳书苑)_第4页
第4页 / 共50页
数据流体系结构风格4(骄阳书苑)_第5页
第5页 / 共50页
点击查看更多>>
资源描述

《数据流体系结构风格4(骄阳书苑)》由会员分享,可在线阅读,更多相关《数据流体系结构风格4(骄阳书苑)(50页珍藏版)》请在金锄头文库上搜索。

1、软件体系结构及应用软件体系结构及应用4 4 数据流体系结构风格数据流体系结构风格1专业课堂主要内容n4.1 数据流体系结构风格的基本特征n4.2 管道-过滤器(pipe-and-filter)n4.3 批处理(batch sequential)n4.4 批处理与管道-过滤器的比较2专业课堂4.1 数据流体系结构风格的基本特征3专业课堂数据流风格的直观理解nA data flow system is one in which the availability of data controls the omputation (数据的可用性决定着处理是否执行) the structure of th

2、e design is dominated by orderly motion of data from process to process (系统结构:数据在各处理之间的有序移动) in a pure data flow system, there is no other interaction between processes (在纯数据流系统中,处理之间除了数据交换,没有任何其他的交互)4专业课堂数据流风格的基本构件(COMPONENT)nComponents: data processing components(基本构件:数据处理) Interfaces are input po

3、rts and output ports ( Interfaces are input ports and output ports (构件接口:输入端口和构件接口:输入端口和输出端口输出端口) ) Input ports read data; output ports write data ( Input ports read data; output ports write data (从输入端口读取数据,从输入端口读取数据,向输出端口写入数据向输出端口写入数据) ) Computational model: read data from input ports, compute, wri

4、te data Computational model: read data from input ports, compute, write data to output ports (to output ports (计算模型:从输入端口读数,经过计算计算模型:从输入端口读数,经过计算/ /处理,然处理,然后写到输出端口后写到输出端口) )5专业课堂数据流风格的连接件(CONNECTOR)nConnectors: data flow (data stream) (连接件:数据流) Uni-directional, usually asynchronous, buffered (单向、通常是

5、异步、单向、通常是异步、有缓冲有缓冲) Interfaces are reader and writer roles (接口角色:接口角色:readerreader和和writerwriter) Computational model (计算模型计算模型: : 把数据从一个处理的输出端口把数据从一个处理的输出端口传送到另一个处理的输入端口传送到另一个处理的输入端口)6专业课堂数据流风格的拓扑结构(TOPOLOGY)7专业课堂数据流VS. 控制流n在von Neumann的计算机体系结构中,有控制流与数据流之分; 控制流(Control flow) 数据流(Data flow)n讨论:二者有什么

6、区别和联系?能否分别举出几个例子?二者有什么区别和联系?能否分别举出几个例子?8专业课堂两种典型的数据流风格nPipe-and-Filter (管道-过滤器)nBatch Sequential (批处理)9专业课堂4.2 管道与过滤器风格PIPE-AND-FILTER10专业课堂从“自来水管道系统”看PIPE-AND-FILTER11专业课堂基本定义n语境:数据源源不断的产生,系统需要对这些数据进行若干处理(分析、计算、转换等)。n解决方案: 把系统分解为几个序贯的处理步骤,这些步骤之间通过数据流连接,一个步骤的输出是另一个步骤的输入; 每个处理步骤由一个过滤器构件(Filter)实现; 处理

7、步骤之间的数据传输由管道(Pipe)负责。n每个处理步骤(过滤器)都有一组输入和输出,过滤器从管道中读取输入的数据流,经过内部处理,然后产生输出数据流并写入管道中。12专业课堂PIPE-AND-FILTER风格的基本构成nComponents: Filters process data streams (构件:过滤器,处理数据流) A filter encapsulates a processing step (algorithm or computation) (一个过滤器封装了一个处理步骤) Data source and data sink are particular filters

8、(数据源点和数据终止点可以看作是特殊的过滤器)nConnectors: A pipe connects a source and a sink filter (连接件:管道,连接一个源和一个目的过滤器) Pipes move data from a filter output to a filter input (转发数据流) Data is a stream of “objects” (数据是特定类型的“对象”流)nTopology: Connectors define data flow graph (连接器定义了数据流图,形成拓扑结构)13专业课堂1 过滤器(FILTER)nIncrem

9、entally transform some of the source data into sink data(目标:将源数据变换成目标数据)nStream to stream transformation (从“数据流” “数据流”的变换) enrich data by computation and adding information (通过计算和增加信息来丰富数据) refine by distilling data or removing irrelevant data (通过浓缩和删减来精炼数据) transform data by changing its representa

10、tion (通过改变数据表现方式来转化数据) decompose data to multiple streams (将一个数据流分解为多个数据流) merge multiple streams into one stream (将多个数据流合并为一个数据流)14专业课堂过滤器对数据流的五种变换类型15专业课堂过滤器读取与处理数据流的方式nIncrementally transform data from the source to the sink (递增的读取和消费数据流) 在输入被完全消费之前,输出便产生了。16专业课堂过滤器的一些基本特征nFilters are independent

11、 entities, i.e., no context in processing streams (无上下文信息) no state preservation between instantiations (不保留状态) no knowledge of upstream/downstream filters (对其他过滤器无任何了解) collections can be used to buffer the data passed through pipes: files,arrays, dictionaries, trees, etc. (可使用数据缓冲区临时保存数据流) 蓄水池17专业

12、课堂2 管道(PIPE)nMove data from a filterMove data from a filters output to a filters output to a filters input (or s input (or to a device or file)(to a device or file)(作用:在过滤器之间传送数据作用:在过滤器之间传送数据) ) One way flow from one data source to one data sink (单向流) A pipe may implement a buffer (可能具有缓冲区) Pipes fo

13、rm data transmission graph (管道形成传输图)n不同的管道中流动的数据流,具有不同的数据格式不同的管道中流动的数据流,具有不同的数据格式(Data format)(Data format)。n原因:数据在流过每一个过滤器时,被过滤器进行了原因:数据在流过每一个过滤器时,被过滤器进行了丰富、精练、转换、融合、分解丰富、精练、转换、融合、分解等操作,因而发生了等操作,因而发生了变化。变化。18专业课堂管道中流动的数据类型nPipe between two threads of a single process (e.g., Java Streams) Stream may

14、 contain references to shared language objectsnPipe between two processes on a single host computer (e.g., UNIX Named Pipes) stream may contain references to shared OS objects (e.g., files)nPipe between two processes in a distributed system (e.g., Internet Sockets) Stream contents limited to raw byt

15、es Protocols implement high-level abstractions (e.g., pass pipes as reference, pass COBA object references)19专业课堂管道中流动的数据类型nTradeoffTradeoff compatibility and reusability everything is a stream vs. type safety stream of Persons, stream of TextsnPopular stream data formatsPopular stream data formats

16、raw byte stream stream of ASCII text lines with line separator record stream (record attributes are strings, separated by tabulator or comma) nested record stream (record attribute is in turn a sequence) stream representing a tree traversal (inner nodes / leaf nodes enumerated in preorder, postorder

17、, inorder) typed stream with a header containing its type information (e.g., column headings) event streams (event name and event arguments)20专业课堂管道-过滤器风格的一些变化形式21专业课堂数据流的分类:推式与拉式nQuestion: what is the force that make data flow? (是什么力量推动数据在管道中流动?)nThree choice, all with force emanating from filters:

18、 Push: data source pushes data in downstream direction (推式:前面的过滤器把新产生的数据推入管道) Pull: data sink pulls data from upstream direction (拉式:随后的过滤器从管道中拉出所需数据) Push/pull: a filter is actively pulling from upstream, computing, and pushing downstream (推拉式:过滤器以循环的方式,从管道中拉出其输入数据,并将其处理产生的数据压入后续管道)22专业课堂过滤器的分类:主动与

19、被动nActive filter: drivers the data flow on the pipes. (主动过滤器:驱动数据流动, pull+push)nPassive filter: is driven by the data flow on the (input/output)pipes. (被动过滤器:被管道中的输入或输出数据流所驱动)nAttention:系统中至少有一个主动过滤器(可以来自外部环境,如用户输入)23专业课堂被动过滤器所采用的两种策略nPull Strategy: The filter is a passive object that is driven by t

20、he subsequent pipeline element that pulls output data from the filter; (采用拉式策略的被动过滤器: 该过滤器不会主动执行,而是在后续 过滤器的“拉”动作的驱动下才执行)nPush Strategy: The filter is a passive object that is driven by the previous pipeline element that pushes input data into the filter. (采用推式策略的被动过滤器:该过滤 器不会主动执行,而是在前续过滤器 的“推”动作的驱动下

21、才执行)24专业课堂采用推式策略的被动过滤器25专业课堂采用拉式策略的被动过滤器26专业课堂一个混合型的管道-过滤器系统27专业课堂一个混合型的管道-过滤器系统28专业课堂带有缓冲区的混合型管道-过滤器系统29专业课堂带有缓冲区的混合型管道-过滤器系统30专业课堂过滤器的状态n停止状态:表示过滤器处于待启动状态,当外部启动过滤器后,过滤器处于处理状态。n处理状态:表示过滤器正处理输入数据队列中的数据。n等待状态:表示过滤器的输入数据队列为空,此时过滤器等待,当有新的数据输入时,过滤器处于处理状态。31专业课堂PIPE-AND-FILTER风格的典型应用32专业课堂PIPE-AND-FILTER

22、风格的典型应用nComplier (scan, parse, generate code, .) (Complier (scan, parse, generate code, .) (编译器编译器) )nUnix pipes (Unix pipes (UnixUnix管道管道) )nImage processing (Image processing (图像处理图像处理) )nSignal processing (Signal processing (信号处理信号处理) )nVoice and video streaming (Voice and video streaming (声音与图像处

23、理声音与图像处理) )n33专业课堂管道-过滤器风格的例子34专业课堂管道-过滤器风格的例子:UNIX SHELL35专业课堂管道-过滤器风格的例子: UNIX SHELL36专业课堂管道-过滤器风格的例子:编译器(1)37专业课堂管道-过滤器风格的例子:编译器(2)38专业课堂管道-过滤器风格的优点n使得系统中的构件具有良好的使得系统中的构件具有良好的隐蔽性和高内聚、低耦隐蔽性和高内聚、低耦合合的特点;的特点;n允许设计者将整个系统的输入允许设计者将整个系统的输入/ /输出行为看成是多个输出行为看成是多个过滤器的行为的过滤器的行为的简单合成简单合成;n支持软件复用支持软件复用: 只要提供适合

24、在两个过滤器之间传送的数据,任何两个只要提供适合在两个过滤器之间传送的数据,任何两个过滤器都可被连接起来;过滤器都可被连接起来;n系统维护和增强系统性能简单系统维护和增强系统性能简单: 新的过滤器可以添加到现有系统中来,旧的可以被改进新的过滤器可以添加到现有系统中来,旧的可以被改进的过滤器替换掉;的过滤器替换掉;n允许对一些如吞吐量、死锁等属性的分析允许对一些如吞吐量、死锁等属性的分析;n支持并行执行支持并行执行: 每个过滤器是作为一个单独的任务完成,因此可与其它每个过滤器是作为一个单独的任务完成,因此可与其它任务并行执行。任务并行执行。39专业课堂管道-过滤器风格的缺点n通常导致进程成为批处

25、理的结构 这是因为虽然过滤器可增量式地处理数据,但它们是独立的,所以设计者必须将每个过滤器看成一个完整的从输入到输出的转换;n不适合处理交互的应用 当需要增量地显示改变时,这个问题尤为严重;n因为在数据传输上没有通用的标准,每个过滤器都增加了解析和合成数据的工作,这样就导致了系统性能下降,并增加了编写过滤器的复杂性。 绝大部分处理时间消耗在格式转换上40专业课堂4.3 顺序批处理风格BATCH SEQUENTIAL STYLE41专业课堂批处理风格的直观结构将用户输入的纸带上的数据写入磁带将磁带作为计算设备的输入,进行计算,得到输出结果打印计算结果42专业课堂批处理风格的直观结构43专业课堂基

26、本定义nProcessing steps are independent programs(每个处理步骤是一个独立的程序)nEach step runs to completion before next step starts(每一步必须在前一步结束后才能开始)nData transmitted as a whole between steps(数据必须是完整的,以整体的方式传递)nTypical applications(典型应用): classical data processing (传统的数据处理) program compilation/computer aided softwar

27、e engineering (程序编译/CASE工具)44专业课堂基本构成nComponents (processing steps) are independent programs(基本构件:独立的应用程序)nConnectors are some type of media - traditionally magnetic tape(连接件:某种类型的媒质)nTopology: Connectors define data flow graph (连接件定义了相应的数据流图,表达拓扑结构)nEach step runs to completion before the next step

28、 begins (每一步骤必须在前一步骤完全结束之后方能开始)45专业课堂示例:批处理风格的系统数据流图(Data Flow Diagram,DFD图)46专业课堂4.4 批处理与管道-过滤器的比较47专业课堂批处理与管道-过滤器的比较n相似点: Decompose task into fixed sequence of computations (把任务分解成为一系列固定顺序的计算单元) Interact only through data passed from one to another (彼此间只通过数据传递交互)48专业课堂批处理与管道-过滤器的比较n不同点:Batch Seque

29、ntialPipe-and-Filtertotal(整体传递数据整体传递数据)coarse grained(构件粒度较大构件粒度较大)high latency (延迟高,实时性差延迟高,实时性差)no concurrency (无并发无并发)incremental(增量增量)fine grained (构件粒度较小构件粒度较小) results starts processing (实时性实时性好好)concurrency possible (可并发可并发)49专业课堂归纳:选择数据流风格的一些原则nTask is dominated by the availability of data (任务由数据的可用性来主导)nData can be moved predictably from process to process (事先知道数据的确切流向)nThere may be a performance penalty in data flow styles,however this depends on many factors (数据的流动带来性能损耗)50专业课堂

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号