Re: aio_suspend can not block
- From: ben <lizp.net@xxxxxxxxx>
- Date: Sun, 14 Dec 2008 02:56:19 -0800 (PST)
On 12月14日, 下午3时57分, ben <lizp....@xxxxxxxxx> wrote:
my_aiocb.aio_buf = foo;
my_aiocb.aio_fildes = fileno(file);
my_aiocb.aio_nbytes = 10;
my_aiocb.aio_offset = 0;
my_aiocb.aio_sigevent.sigev_notify = SIGEV_THREAD;
my_aiocb.aio_sigevent.sigev_notify_function = aio_handler;
my_aiocb.aio_sigevent.sigev_value.sival_int = 0;
my_aiocb.aio_sigevent.sigev_notify_attributes = NULL;
//aio_write(&my_aiocb);
const struct aiocb *cblist[2] = {&my_aiocb, NULL};
struct timespec rem = { 10000000, 0 };
int ret = 0;
while ( ret == 0)
//while(1)
{
ret = aio_suspend( cblist, 2, &rem );
printf("get one signal, reg is %d\n", ret);
sleep(1);
}
I think aio_suspend should block, because no signal, but i am wrong,
and the out is :
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
get one signal, reg is 0
why ? thank u
找到原因了,ret = aio_suspend( cblist, 2, &rem );只是阻塞IO操作,由于读的东西太少,很快读完了,所以我
认
为没有阻塞,其实已经阻塞了,用一个大文件读取的时候就看出来了。确实阻塞了。
.
- References:
- aio_suspend can not block
- From: ben
- aio_suspend can not block
- Prev by Date: aio_suspend can not block
- Next by Date: Re: How can I detect remote socket close when I use an epoll ?programming style?
- Previous by thread: aio_suspend can not block
- Next by thread: Re: aio_suspend can not block
- Index(es):