RE: TCP memory pressure question

From: David Schwartz (davids@webmaster.com)
Date: Sat Nov 23 2002 - 17:54:12 EST


On Sat, 23 Nov 2002 23:34:15 +0100, Folkert van Heusden wrote:

>What about:

>int WRITE(int handle, char *whereto, int len)
>{
>int cnt=len;
>
>while(len>0)
>{
>int rc;
>
>rc = write(handle, whereto, len);
>
>if (rc == -1)
>{
>if (errno == EINTR)
> {
> /* just try again */
> }
> else if (errno == EAGAIN)
> {
> /* give up time-slice */
> if (sched_yield() == -1)
> {

        By yielding your time slice, you prevent yourself from performing any
'read's. So what's going to fix the memory pressure?

        There are two cases where this could work:

        1) For an application that uses very little TCP memory. By yielding, perhaps
some other process will come along, a more heavy TCP memory user, and fix the
problem.

        2) For an application that uses a thread-per-connection architecture. By
yielding, we give other threads a chance to run and hope that they will
relieve the memory pressure.

        But for a poll/select loop application that is heavily using TCP memory,
this makes things worse. By stopping our own execution, we delay the time
when we'll do 'read's. So we extend the TCP memory pressure problem for even
longer.

        DS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:43 EST