Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

poll()

0 views
Skip to first unread message

mukesh

unread,
Dec 12, 2006, 9:33:19 AM12/12/06
to
is the following statement is valid one, and is alternative to sleep(),
if we want to calculate time in milli seconds.

poll((struct pollfd *)NULL,0,5);

if we want to sleep for five seconds. Is the above statement valid ? Is
it fullfills the objective.

Mukesh.

loic...@gmx.net

unread,
Dec 12, 2006, 9:53:15 AM12/12/06
to
Hello,

No, this statement is not valid as 5 ms != 5 sec.

You may look at alternative, like /usleep()/ or /nanosleep()/ if your
system has those functions.

Cheers,
Loic.

Casper H.S. Dik

unread,
Dec 12, 2006, 10:46:59 AM12/12/06
to
"mukesh" <mukes...@gmail.com> writes:

>poll((struct pollfd *)NULL,0,5);

But poll sleeps milliseconds, not seconds.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

mukesh

unread,
Dec 13, 2006, 9:18:48 AM12/13/06
to
Loic,
you know that poll takes third argument i.e time to sleep in milli
seconds. are u agree ?

mukesh

unread,
Dec 13, 2006, 9:23:38 AM12/13/06
to
Casper ,
You are right, it was by mistake I have used the words seconds. I mean
milliseconds, then that statement is valid or not.

>if we want to sleep for five seconds
here it is if we want to sleep for five milli seconds. sorry, for that.

loic...@gmx.net

unread,
Dec 13, 2006, 9:36:26 AM12/13/06
to
Hello,

> you know that poll takes third argument i.e time to sleep in milli
> seconds. are u agree ?

absolutely. That's why you wouldn't wait 5 seconds as mentionned in
your first post but 5 ms... But perhaps you meant the later!

In all cases, check out for the availability of /usleep()/ or
/nanosleep()/.

Cheers,
Loic.

0 new messages