Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe there is no good reason to make your process wake up if it has nothing to do. Simply set the timeout to when you first <em>need</em> to do something. For example, if your server has a semantic of disconnecting a client after N seconds of inactivity, set the epoll timeout to the time after the first client would have to be disconnected assuming no activity. In other words, set it to:</p> <p>min{expire_time(client); for each client} - current_time</p> <p>Or, if that's negative, you can disconnect at least one client immediately. In general, this works not only for disconnecting clients; you can abstract the above into "software timers" within your application.</p> <p>I'm failing to see this compromise you've mentioned. If you use a timeout any smaller than you have to, you'll wake up before you <em>have</em> to, then, presumably, go back to sleep because you have nothing to do. What good does that do? On the other hand, you <em>must not</em> use a timeout any larger than what you have to - because that would make your program not respect the disconnect timeout policy.</p> <p>If your program is not waiting for any time-based event (like disconnecting clients), just give epoll_wait() timeout value -1, making it wait forever.</p> <p><strong>UPDATE</strong> If you're worried that this process being given less CPU when other processes are active, just give it lower nice value (scheduler priority). On the other hand, if you're worried that your server process will be swapped out to disk in favour of other processes when it's idle, it is possible to <a href="https://unix.stackexchange.com/questions/10214/per-process-swapiness-for-linux">avoid swapping it out</a>. (or you can just lower /proc/sys/vm/swappiness, affecting all processes)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload