Re: Suggestions for my Linux app...?

On 2007-01-17, trashman.horlicks@xxxxxxxxxxxxxx <trashman.horlicks@xxxxxxxxxxxxxx> wrote:
Like this?

struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 200000; /* 0.2 seconds */
select (0, NULL, NULL, NULL, &tv);

that'd work.

usleep(200000) would have the same effect.

nanosleep would be another option. (usleep is easier to use)

If it's for a server typically you use select and list put the FD of all the
sockets you're listening on in the readfds... and any with writes pending
in the writefds


Relevant Pages

  • Possible spin-problem in nanosleep()
    ... The man pages say usleep() is obsolete and one should ... nanosleep() appears to have a problem. ... little or no CPU time as shown by `top`. ... and it sleeps for 100 milliseconds also. ...
  • Re: Call for Running -> Ready state
    ... Lorenz Brittinger writes: ... > Ready state so that the process is reactivated on its next time slice. ... nanosleep or usleep. ... nanosleep is more standardized, but usleep is ...
  • Re: High res timer?
    ... > nanosleep() seems to have some latency very similar to usleep(). ... send the line "unsubscribe linux-kernel" in ...
  • Re: How to "sleep" or "delay"?
    ... > man 3 sleep ... > And for shorter times: ... > man 3 usleep ... > man 2 nanosleep ...