[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]
8、存储映射I/O
[/size]
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]