Chapter 14

[size=medium]
1、永远阻塞的调用有哪些?
  阻塞,直到函数调用完成为止,否则一直等待。


2、标志位操作
[url]http://xserver.iteye.com/blog/784840[/url]
  set_fl clr_fl


3、轮询(polling)。主动。内核不断尝试,是否能进行I/O
使用了非阻塞,程序不断调用write,但是又没有数据,造成浪费。

  异步I/O(asynchronous I/O)。被动。通知内核进行I/O
[url]http://www.groad.net/bbs/simple/?t950.html[/url]


4、线程在I/O调用中阻塞,但线程间同步的开销有可能增加复杂性,可能导致得不偿失。


5、读锁、写锁、局部锁(记录锁,record locking,更适合的术语byte-range locking)
  5.2 锁的继承与释放(多进程 与 单进程效果不同)
p.s 不能测试自己加的锁。只会返回F_UNLCK :cry:
[url]http://blog.chinaunix.net/u/30503/showart_2327622.html[/url]
[url]http://www.linuxdiyf.com/bbs/redirect.php?tid=84178&goto=lastpost[/url]

6、STREAMS


7、I/O多路转接(I/O multiplexing)[/size]

#include <sys/select.h>
int select(int maxfdpl,
fd_set *restrict readfds, // 可读
fd_set *restrict writefd,  // 可写
fd_set *restrict exceptfds, // 异常
struct timeval *restrict tvptr); // 等待的时间

// restrict是c99引入的,它只可以用于限定指针,并表明指针是访问一个数据对象的唯一且初始的方式

#include <poll.h>
int poll(struct pollfd fdarray[], nfds_t nfds, int timeout);

#include <sys/uio.h> // 散布读(scatter read)聚集写(gather write)
ssize_t readv(int filedes, const struct iovec *iov, int iovcnt);
ssize_t writev(int filedes, const struct iovec *iov, int iovcnt);


[size=medium]


8、存储映射I/O
[/size]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值