1. I/O模型
Unix下共有五种I/O模型
a. 阻塞I/O
b. 非阻塞I/O
c. I/O复用(select和poll)
d. 信号驱动I/O(SIGIO)
e. 异步I/O(Posix.1的aio_系列函数)
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
相关推荐
在嵌入式系统开发中,LCD(Liquid Crystal Display,液晶显示器)作为一种常见的显示设备,以其低功耗、高信息承载量及小巧体积的特点,被广泛应用于各类MCU(Microcontroller Unit,微控制器单元)系统中。...
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();...
"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...
"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...
"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...
"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...
可以传递每个命令-- NAME_OF_SERVICE以启动微服务(应用程序名称与它们所在的目录匹配) # development$ npm run start# watch mode$ npm run start:dev# production mode$ npm run start:prod测试# unit tests$ ...
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 ...
为了实现 IO Determinism,NVMe 1.4 协议引入了三个主要的组成部分:NVM Sets、PLM(Predictable Latency Mode)和 RRL(Read Recovery Level)。 1. NVM Sets NVM Sets 是 NVMe 1.4 协议中的一项新功能,它允许对...
检查清单IAM角色: AvbxApiServer AmazonDynamoDBFullAccess KMS对称密钥将AvbxApiServer添加为关键用户安装$ npm install运行应用# development$ npm run start# watch mode$ npm run start:dev# production mode$ ...
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, ...
- 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 + ...
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 ...
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 ...
PDU Mode(Protocol Data Unit)是最常见的编码方式,尤其适用于处理Unicode(UCS2)编码的文本,如中文短信。在PDU Mode下,每个字符最多可发送70个16-bit编码的字符。例如,发送“你好,Hello!”这条包含中文和...
- **TSG-04: AC Common Mode Voltage**:交流共模电压测试。 - **PHY-01: Unit Interval**:单位间隔测试。 - **TSG-05: Rise/Fall Imbalance**:上升/下降不平衡测试。 - **PHY-02: Frequency Long Term Stability*...
Block Mode已经较为少见,Text Mode适合简单的文本短信,而PDU(Protocol Data Unit)Mode则是目前广泛采用的模式,尤其在处理复杂字符集如Unicode时。以16-bit的UCS2编码为例,每条短信最多能包含70个字符,包括...
# $(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....
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 ...
* 高速IO口:最多114个IO口,支持高速数据传输 * 通信接口:最多17个,包括UART、SPI、I2C、I2S、CAN、USB OTG FS等 五、电源管理 * 运行模式:112 µA/MHz(外设关闭) * 停止模式(Flash在停止模式,快速唤醒)...