1 Star 7 Fork 13

刘丹冰Aceld / libevent

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
21-流-io.md 840 Bytes
Copy Edit Raw Blame History
aceld authored 2016-07-15 14:04 . Creates assets/libevent-2-阻塞02.png

2.1 流?I/O操作/阻塞

2.1.1 流

  • 可以进行I/O操作的内核对象
  • 文件、管道、套接字……
  • 流的入口:文件描述符(fd)

2.1.2 I/O操作



所有对流的读写操作,我们都可以称之为IO操作。

那么当一个流中再没有数据,read的时候,或者说在流中已经写满了数据,再write,我们的IO操作就会出现一种现象,就是阻塞现象。

2.1.2 阻塞



  • 阻塞等待

空出大脑可以安心睡觉。(不占用CPU宝贵的时间片)

  • 非阻塞,忙轮询

浪费时间,浪费电话费,占用快递员时间(占用CPU,系统资源)

1
https://gitee.com/Aceld/libevent.git
git@gitee.com:Aceld/libevent.git
Aceld
libevent
libevent
master

Search