




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、软件体系结构及应用软件体系结构及应用4 4 数据流体系结构风格数据流体系结构风格1 1专业课堂主要内容n4.1 数据流体系结构风格的基本特征n4.2 管道-过滤器(pipe-and-filter)n4.3 批处理(batch sequential)n4.4 批处理与管道-过滤器的比较2 2专业课堂4.1 数据流体系结构风格的基本特征3 3专业课堂数据流风格的直观理解na data flow system is one in which the availability of data controls the omputation (数据的可用性决定着处理是否执行) the structure
2、 of the 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 4专业课堂数据流风格的基本构件(component)ncomponents: data processing components(基本构件:数据处理) interfaces are
3、input ports 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, comp
4、ute, write data computational model: read data from input ports, compute, write data to output ports (to output ports (计算模型:从输入端口读数,经过计算计算模型:从输入端口读数,经过计算/ /处理,处理,然后写到输出端口然后写到输出端口) )5 5专业课堂数据流风格的连接件(connector)nconnectors: data flow (data stream) (连接件:数据流) uni-directional, usually asynchronous, buffer
5、ed (单向、通常是异步、单向、通常是异步、有缓冲有缓冲) interfaces are reader and writer roles (接口角色:接口角色:readerreader和和writerwriter) computational model (计算模型计算模型: : 把数据从一个处理的输出端口把数据从一个处理的输出端口传送到另一个处理的输入端口传送到另一个处理的输入端口)6 6专业课堂数据流风格的拓扑结构(topology)7 7专业课堂数据流vs. 控制流n在von neumann的计算机体系结构中,有控制流与数据流之分; 控制流(control flow) 数据流(data
6、flow)n讨论:二者有什么区别和联系?能否分别举出几个例子?二者有什么区别和联系?能否分别举出几个例子?8 8专业课堂两种典型的数据流风格npipe-and-filter (管道-过滤器)nbatch sequential (批处理)9 9专业课堂4.2 管道与过滤器风格pipe-and-filter1010专业课堂从“自来水管道系统”看pipe-and-filter1111专业课堂基本定义n语境:数据源源不断的产生,系统需要对这些数据进行若干处理(分析、计算、转换等)。n解决方案: 把系统分解为几个序贯的处理步骤,这些步骤之间通过数据流连接,一个步骤的输出是另一个步骤的输入; 每个处理步骤
7、由一个过滤器构件(filter)实现; 处理步骤之间的数据传输由管道(pipe)负责。n每个处理步骤(过滤器)都有一组输入和输出,过滤器从管道中读取输入的数据流,经过内部处理,然后产生输出数据流并写入管道中。1212专业课堂pipe-and-filter风格的基本构成ncomponents: filters process data streams (构件:过滤器,处理数据流) a filter encapsulates a processing step (algorithm or computation) (一个过滤器封装了一个处理步骤) data source and data sink
8、 are particular filters (数据源点和数据终止点可以看作是特殊的过滤器)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
9、13专业课堂1 过滤器(filter)nincrementally 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 b
10、y changing its representation (通过改变数据表现方式来转化数据) decompose data to multiple streams (将一个数据流分解为多个数据流) merge multiple streams into one stream (将多个数据流合并为一个数据流)1414专业课堂过滤器对数据流的五种变换类型1515专业课堂过滤器读取与处理数据流的方式nincrementally transform data from the source to the sink (递增的读取和消费数据流) 在输入被完全消费之前,输出便产生了。1616专业课堂过滤器
11、的一些基本特征nfilters are independent entities, i.e.,filters are independent 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 pi
12、pes: files,arrays, dictionaries, trees, etc. (可使用数据缓冲区临时保存数据流) 蓄水池1717专业课堂2 管道(pipe)nmove data from a filtermove data from a filter s output to a filters output to a filter s input (or to a s input (or to a device or file)(device or file)(作用:在过滤器之间传送数据作用:在过滤器之间传送数据) ) one way flow from one data sour
13、ce to one data sink (单向流) a pipe may implement a buffer (可能具有缓冲区) pipes form data transmission graph (管道形成传输图)n不同的管道中流动的数据流,具有不同的数据格式不同的管道中流动的数据流,具有不同的数据格式(data format)(data format)。n原因:数据在流过每一个过滤器时,被过滤器进行原因:数据在流过每一个过滤器时,被过滤器进行了了丰富、精练、转换、融合、分解丰富、精练、转换、融合、分解等操作,因而发等操作,因而发生了变化。生了变化。1818专业课堂管道中流动的数据类型n
14、pipe between two threads of a single process (e.g., java streams) stream may 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 di
15、stributed system (e.g., internet sockets) stream contents limited to raw bytes protocols implement high-level abstractions (e.g., pass pipes as reference, pass coba object references)1919专业课堂管道中流动的数据类型ntradeofftradeoff compatibility and reusability everything is a stream vs. type safety stream of pe
16、rsons, stream of textsnpopular stream data formatspopular stream data formats 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 representin
17、g a tree traversal (inner nodes / leaf nodes enumerated in preorder, postorder, inorder) typed stream with a header containing its type information (e.g., column headings) event streams (event name and event arguments)2020专业课堂管道-过滤器风格的一些变化形式2121专业课堂数据流的分类:推式与拉式nquestion: what is the force that make
18、data flow? (是什么力量推动数据在管道中流动?)nthree choice, all with force emanating from filters: 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, a
19、nd pushing downstream (推拉式:过滤器以循环的方式,从管道中拉出其输入数据,并将其处理产生的数据压入后续管道)2222专业课堂过滤器的分类:主动与被动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:系统中至少有一个主动过滤器(可以来自外部环境,如用户输入)2
20、323专业课堂被动过滤器所采用的两种策略npull strategy: the filter is a passive object that is driven by the 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
21、 that pushes input data into the filter. (采用推式策略的被动过滤器:该过滤 器不会主动执行,而是在前续过滤器 的“推”动作的驱动下才执行)2424专业课堂采用推式策略的被动过滤器2525专业课堂采用拉式策略的被动过滤器2626专业课堂一个混合型的管道-过滤器系统2727专业课堂一个混合型的管道-过滤器系统2828专业课堂带有缓冲区的混合型管道-过滤器系统2929专业课堂带有缓冲区的混合型管道-过滤器系统3030专业课堂过滤器的状态n停止状态:表示过滤器处于待启动状态,当外部启动过滤器后,过滤器处于处理状态。n处理状态:表示过滤器正处理输入数据队列中的数
22、据。n等待状态:表示过滤器的输入数据队列为空,此时过滤器等待,当有新的数据输入时,过滤器处于处理状态。3131专业课堂pipe-and-filter风格的典型应用3232专业课堂pipe-and-filter风格的典型应用ncomplier (scan, parse, generate code, .) (complier (scan, parse, generate code, .) (编译器编译器) )nunix pipes (unix pipes (unixunix管道管道) )nimage processing (image processing (图像处理图像处理) )nsignal
23、 processing (signal processing (信号处理信号处理) )nvoice and video streaming (voice and video streaming (声音与图像处理声音与图像处理) )n3333专业课堂管道-过滤器风格的例子3434专业课堂管道-过滤器风格的例子:unix shell3535专业课堂管道-过滤器风格的例子: unix shell3636专业课堂管道-过滤器风格的例子:编译器(1)3737专业课堂管道-过滤器风格的例子:编译器(2)3838专业课堂管道-过滤器风格的优点n使得系统中的构件具有良好的使得系统中的构件具有良好的隐蔽性和高内
24、聚、低隐蔽性和高内聚、低耦合耦合的特点;的特点;n允许设计者将整个系统的输入允许设计者将整个系统的输入/ /输出行为看成是多个输出行为看成是多个过滤器的行为的过滤器的行为的简单合成简单合成;n支持软件复用支持软件复用: 只要提供适合在两个过滤器之间传送的数据,任何两个只要提供适合在两个过滤器之间传送的数据,任何两个过滤器都可被连接起来;过滤器都可被连接起来;n系统维护和增强系统性能简单系统维护和增强系统性能简单: 新的过滤器可以添加到现有系统中来,旧的可以被改进新的过滤器可以添加到现有系统中来,旧的可以被改进的过滤器替换掉;的过滤器替换掉;n允许对一些如吞吐量、死锁等属性的分析允许对一些如吞吐
25、量、死锁等属性的分析;n支持并行执行支持并行执行: 每个过滤器是作为一个单独的任务完成,因此可与其它每个过滤器是作为一个单独的任务完成,因此可与其它任务并行执行。任务并行执行。3939专业课堂管道-过滤器风格的缺点n通常导致进程成为批处理的结构 这是因为虽然过滤器可增量式地处理数据,但它们是独立的,所以设计者必须将每个过滤器看成一个完整的从输入到输出的转换;n不适合处理交互的应用 当需要增量地显示改变时,这个问题尤为严重;n因为在数据传输上没有通用的标准,每个过滤器都增加了解析和合成数据的工作,这样就导致了系统性能下降,并增加了编写过滤器的复杂性。 绝大部分处理时间消耗在格式转换上4040专业
26、课堂4.3 顺序批处理风格batch sequential style4141专业课堂批处理风格的直观结构将用户输入的纸带上的数据写入磁带将磁带作为计算设备的输入,进行计算,得到输出结果打印计算结果4242专业课堂批处理风格的直观结构4343专业课堂基本定义nprocessing steps are independent programs(每个处理步骤是一个独立的程序)neach step runs to completion before next step starts(每一步必须在前一步结束后才能开始)ndata transmitted as a whole between steps
27、(数据必须是完整的,以整体的方式传递)ntypical applications(典型应用): classical data processing (传统的数据处理) program compilation/computer aided software engineering (程序编译/case工具)4444专业课堂基本构成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 begins (每一步骤必须在前一步骤完全结束之后方能开始)4545专业课堂示例:批处理风格的系统数据流图(dat
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年谷物细粉项目提案报告
- 家居用品进销存大数据平台合作协议
- 环境治理承诺责任书8篇
- 2025年嘧菌酯项目提案报告
- 互联网交易平台诚实交易承诺书(3篇)
- 企业创新与质量承诺函4篇范文
- 2025年上半年内江市部分学校公开考试招聘教师、部分事业单位公开考试招聘工作人员笔试模拟试卷含答案详解
- 电商销售商品售后服务承诺函9篇范文
- 企业文化建设活动策划执行方案
- 高新技术产品使用保证承诺书4篇
- 2025至2030全球及中国车辆排放传感器行业发展趋势分析与未来投资战略咨询研究报告
- 直管到户管理办法
- 2025门窗买卖销售订购确认书
- DGTJ08-2310-2019 外墙外保温系统修复技术标准
- 软件开发分包管理措施
- 2025至2030中国碳刷行业产业运行态势及投资规划深度研究报告
- 新生儿喉罩应用技术规范
- 2025年富通集团有限公司校园招聘模拟试题完整
- 汽车衡过磅管理制度
- 厨部成本控制培训
- 2024北森图形推理题
评论
0/150
提交评论