`

IO mode of Unit

 
阅读更多

1. I/O模型 
Unix
下共有五种I/O模型 
a.
阻塞I/O 
b.
非阻塞I/O 
c. I/O
复用(selectpoll 
d.
信号驱动I/OSIGIO 
e.
异步I/OPosix.1aio_系列函数) 
1). 
阻塞I/O模型 
应用程序调用一个IO函数,导致应用程序阻塞,等待数据准备好。 
如果数据没有准备好,一直等待。。。。 
数据准备好了,从内核拷贝到用户空间 
I/O
函数返回成功指示

 

2). 非阻塞I/O模型 
我们把一个套接口设置为非阻塞就是告诉内核,当所请求的I/O操作无法完成时,不要将进程睡眠,而是返回一个错误。这样我们的I/O操作函数将不断的测试数据是否已经准备好,如果没有准备好,继续测试,直到数据准备好为止。在这个不断测试的过程中,会大量的占用CPU的时间。

 

3). I/O复用模型 
I/O
复用模型会用到select或者poll函数,这两个函数也会使进程阻塞,但是和阻塞I/O所不同的的,这两个函数可以同时阻塞多个I/O操作。而且可以同时对多个读操作,多个写操作的I/O函数进行检测,直到有数据可读或可写时,才真正调用I/O操作函数。 

4). 
信号驱动I/O模型 
首先我们允许套接口进行信号驱动I/O,并安装一个信号处理函数,进程继续运行并不阻塞。当数据准备好时,进程会收到一个SIGIO信号,可以在信号处理函数中调用I/O操作函数处理数据。


5). 
异步I/O模型 
调用aio_read函数,告诉内核描述字,缓冲区指针,缓冲区大小,文件偏移以及通知的方式,然后立即返回。当内核将数据拷贝到缓冲区后,再通知应用程序。


2. 
几种I/O模型的比较 
前四种模型的区别是第一阶段基本相同,第二阶段基本相同,都是将数据从内核拷贝到调用者的缓冲区。而异步I/O的两个阶段都不同于前四个模型。

 

3. 同步I/O和异步I/O 
a.
同步I/O操作引起请求进程阻塞,直到I/O操作完成。 
异步I/O操作不引起请求进程阻塞。 
b.
我们的前四个模型都是同步I/O,只有最后一个异步I/O模型是异步I/O 

部分内容来自:http://blog.csdn.net/sunyubo458/archive/2010/12/24/6096723.aspx

分享到:
评论

相关推荐

    IO口驱动lcd介绍

    在嵌入式系统开发中,LCD(Liquid Crystal Display,液晶显示器)作为一种常见的显示设备,以其低功耗、高信息承载量及小巧体积的特点,被广泛应用于各类MCU(Microcontroller Unit,微控制器单元)系统中。...

    QR.NET-master.zip_QRCODE_asp.net_drawing_web打印 二维码_二维码

    System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.OpenOrCreate,System.IO.FileAccess.Write); printPicture.Save(fs, System.Drawing.Imaging.ImageFormat.Png); fs.Close();...

    BX2400蓝牙JLINK程序烧录工具包

    "We are delighted to announce BlueX as a licensee for our Bluetooth IP," said Aviv Malinovitch, vice president and general manager of the Connectivity Business Unit at CEVA. "The adoption of the BX...

    BX2400开发文档

    "We are delighted to announce BlueX as a licensee for our Bluetooth IP," said Aviv Malinovitch, vice president and general manager of the Connectivity Business Unit at CEVA. "The adoption of the BX...

    BX2400_BLE_SDK_V1.6_3697.zip

    "We are delighted to announce BlueX as a licensee for our Bluetooth IP," said Aviv Malinovitch, vice president and general manager of the Connectivity Business Unit at CEVA. "The adoption of the BX...

    BX2400_BlueX_PCB库文件.rar

    "We are delighted to announce BlueX as a licensee for our Bluetooth IP," said Aviv Malinovitch, vice president and general manager of the Connectivity Business Unit at CEVA. "The adoption of the BX...

    微服务生态系统:考虑微服务架构的MMORPG生态系统

    可以传递每个命令-- NAME_OF_SERVICE以启动微服务(应用程序名称与它们所在的目录匹配) # development$ npm run start# watch mode$ npm run start:dev# production mode$ npm run start:prod测试# unit tests$ ...

    ABB机器人系统信号介绍1.1.pdf

    16. **Simulated IO**: 模拟输入/输出信号,用于测试。 17. **Mechanical Unit Active**: 机械单元已激活,准备运行。 18. **Task Executing**: 正在执行任务。 19. **Mechanical Unit Not Moving**: 机械单元未运动...

    [Mastering.Node.js(2013.11) 精通Node.js

    Unit tests 257 Functional tests 257 Integration tests 258 Native Node testing and debugging tools 259 Writing to the console 259 Formatting console output 261 The Node debugger 263 The assert module ...

    NVMe1.4协议三大新功能解读.docx

    为了实现 IO Determinism,NVMe 1.4 协议引入了三个主要的组成部分:NVM Sets、PLM(Predictable Latency Mode)和 RRL(Read Recovery Level)。 1. NVM Sets NVM Sets 是 NVMe 1.4 协议中的一项新功能,它允许对...

    avatarbox.api:avatarbox.io的其余api

    检查清单IAM角色: AvbxApiServer AmazonDynamoDBFullAccess KMS对称密钥将AvbxApiServer添加为关键用户安装$ npm install运行应用# development$ npm run start# watch mode$ npm run start:dev# production mode$ ...

    moxa-mxview-plugin-for-mgate-series-software-package-v2.5.zip

    PROFINET IO Device: PROFINET communication is exchanging data Red (Flashing only) A communication error occurred Modbus TCP Client: 1. Received an exception code or framing error (parity error, ...

    Bochs - The cross platform IA-32 (x86) emulator

    - Ported most of Qemu's 'virtual VFAT' block driver (except runtime write support, but plus FAT32 suppport) - Added write protect option for floppy drives. - Bugfixes / improved internal debugger + ...

    acpi控制笔记本风扇转速

    semaphore was inadvertently created with one unit instead of zero units. (BZ 464) Fiodor Suietov. Fixed a possible memory leak and fault in AcpiExResolveObjectToValue during a read from a buffer or ...

    BobBuilder_app

    Two mode of operation Flush immediate and Deferred ( the latter being faster at the expense of the risk of non-clean shutdown data loss). Enumerate the index is supported. Enumerate the Storage file ...

    C#开发终端式短信的原理和方法

    PDU Mode(Protocol Data Unit)是最常见的编码方式,尤其适用于处理Unicode(UCS2)编码的文本,如中文短信。在PDU Mode下,每个字符最多可发送70个16-bit编码的字符。例如,发送“你好,Hello!”这条包含中文和...

    c#短信开发c#短信开发

    Block Mode已经较为少见,Text Mode适合简单的文本短信,而PDU(Protocol Data Unit)Mode则是目前广泛采用的模式,尤其在处理复杂字符集如Unicode时。以16-bit的UCS2编码为例,每条短信最多能包含70个字符,包括...

    8188eu_sc3817r_sina33服务器验证通过_带rtl8188eu的驱动程序_20170619_1108没有外层目录.7z

    # $(call find-copy-subdir-files,*,device/softwinner/polaris-common/rild/usb_modeswitch.d,system/etc/usb_modeswitch.d) #PRODUCT_PACKAGES += Bluetooth #PRODUCT_PROPERTY_OVERRIDES += \ # ro.product....

    SATA接口一致性测试

    - **TSG-04: AC Common Mode Voltage**:交流共模电压测试。 - **PHY-01: Unit Interval**:单位间隔测试。 - **TSG-05: Rise/Fall Imbalance**:上升/下降不平衡测试。 - **PHY-02: Frequency Long Term Stability*...

    occam一维反演

    C OF THE FORWARD PROBLEM, AND TO MAKE MAXIMUM USE OF DYNAMIC MEMORY ALLOCATION, C AS THE ARRAY SIZES FOR THE 2D PROBLEM ARE NOW GETTING TOO LARGE FOR COMFORT. C INCLUDE FILES ARE NOW USED TO ...

Global site tag (gtag.js) - Google Analytics