aio_suspend can not block

aio_suspend can not block

Post by ben » Mon, 15 Dec 2008 16:57:34


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
 
 
 

aio_suspend can not block

Post by ben » Mon, 15 Dec 2008 19:56:19


ret = aio_suspend( cblist, 2, &rem );IO

 
 
 

aio_suspend can not block

Post by David Schw » Mon, 15 Dec 2008 23:54:30


> my_aiocb.aio_nbytes>= 10;
> my_aiocb.aio_o>fset = 0;
> my_aiocb.aio_sigevent.sigev_notify =>SIGEV_THREAD;
> my_aiocb.aio_sigevent.sigev_notify_funct>on = aio_handler;
> my_aiocb.aio_sigevent.sige>_value.sival_int = 0;
> my_aiocb.aio_sigevent.sigev>no>ify_attributes = NULL;
>
> gt;//aio_write(&my_aiocb);
> onst struct aio>b *cblist[2] = {&my_aiocb, NULL};
> gt;truct timespec rem =>{ 10000000, 0 };
> > nt ret = 0; >> > while ( ret == 0)
> //while(1)
> > {
> ret = aio_suspend( cblist, 2, >rem );
> > pri>tf>"get one signal, reg is %d\n", ret);
> sleep(1);
> > }
>
> I thin> aio_suspend should block, >ecause no signal, but i am wrong,
> and the out is :
> get one signal, reg is 0
> why ? thank u

Your code doesn't make sense. What are you trying to wait *for*?

DS
 
 
 

aio_suspend can not block

Post by Daniel Mol » Tue, 16 Dec 2008 00:28:08

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ben < XXXX@XXXXX.COM >
on Sunday 14 December 2008 04:57
wrote in comp.unix.programmer:



Consider doing a RTFM. aio_suspend(2) system call the execution blocks until
the aio request has been completed, and then return 0 if one or more aio
operations has been commited. Then, it's possible that your program
compeltes the operations, and then returns zero too fast for your eyes.

The while statement has no sense, because aio_suspend(2) blocks the
execution for you, and that while that looks like a spin-lock isn't
necessary.

Best regards,
- --
.O. | Daniel Molina Wegener | FreeBSD & Linux
..O | dmw [at] coder [dot] cl | Open Standards
OOO | http://www.yqcomputer.com/ | FOSS Developer

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEARECAAYFAklFJgsACgkQxyPEFPXO3WFDfQCfUvb9ImO4aOlZHqOg3tGqhZmN
tqUAnAgTFeGN3xHpygxbVZcdRZVAaxS/
=54N4
-----END PGP SIGNATURE-----