Re: NutThreadYield() in NutTcpReceive()

Ole Reinhardt <ole.reinhardt-L1vi/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <[email protected]>
Hi Vlaidimir and all others,

thank you very much for your patch. Indeed I do not understand the
reason, why these NutThreadYields had been placed in these functions.

It in deed tuned out, that removing these yields improved the stream
throughput reasonably.

I removed these yields by default but added a new configurator option
TCP_REENABLE_THREADYIELDS to re-enable the yields again.

Best regards,

Ole Reinhardt

Am 23.11.2015 um 13:09 schrieb Vladimir Isaev:
> Hi!
> 
> In our project we use the Nut/Net TCP stack for a small HTTP server
> implementation. It was noticed it works very slow due to current
> NutTcpReceive() implementation: every time it is invoked it calls
> NutThreadYield() just at the very beginning, yielding the time to
> all other threads before it finally reads the next piece of data.
> Thus, when the program wants to read a lot of small pieces of data
> from a TCP stream (for instance, by calling fgets() on the stream),
> then it yields the CPU to other threads *for every char* dramatically
> slowing down the process.
> 
> Finally, we have decided to remove the NutThreadYield() call from
> NutTcpReceive() (and NutTcpSend() too). With this patch calling
> fgets() on a TCP stream works much faster. As to the yielding of
> CPU time, it is possible (and resonable) to call NutThreadYield()
> at a higher level, outside of TCP stack, without forcing a yield
> on every send/receive operation, isn't it?
> 
> Index: nut/net/tcpsm.c
> ===================================================================
> --- nut/net/tcpsm.c     (revision 6229)
> +++ nut/net/tcpsm.c     (working copy)
> @@ -884,7 +884,6 @@
>      if (sock == NULL) {
>          return -1;
>      }
> -    NutThreadYield();
> 
>      switch (sock->so_state) {
>      case TCPS_LISTEN:
> Index: nut/net/tcpsock.c
> ===================================================================
> --- nut/net/tcpsock.c   (revision 6229)
> +++ nut/net/tcpsock.c   (working copy)
> @@ -536,7 +536,6 @@
>      /*
>       * Check parameters.
>       */
> -    NutThreadYield();
> 
> [email protected]
> -    NutThreadYield();
>      /*
>       * Check parameters.
>       */
> 

-- 
kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen
http://www.embedded-it.de
http://www.kernelconcepts.de
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.