Buffer handling DHCP vs. Web server

this is my first posting here. I have a project using an AVR Xmega (Arduino ++) and I’ve ported the web server to this CPU. It is in a freeRTOS environment and is the first web server for the Xmega running smoothly opposite to all Arduino versions for WIZ550. Currently I only have the web server running. I do not understand how the access to the TX_BUF is synchronized between DHCP and web server. I saw that there is a socket reserved for DHCP and some for web server. So the sockets are separate but how the buffers for both services are separated?

As second: In freeRTOS I have one thread running the web server and a second thread running DHCP. Does it make sense to keep both services separate or is it better to have both in one thread as in main.c?

Hello, kschwi.

I did not understand what the meaning of the synchronization you were talking about was.

However, I reply to the contents that can be answered.

  1. DHCP, WebServer sockets are separated and buffers are also separated. (In hardware)
    Of course, the software also uses a different buffer for Send / Receive.

  2. What’s better depends on how you use it.
    In the case of DHCP, packets are sent and received only at a specific time, so it does not matter whether a polling method or a task method is used.
    If you can optimize just about any way, that’s the best way.

Best regard,

Hi Kel,
thanks for your reply. My problem based on misinterpretation of the main function. Based on the lot of #ifdef I did not realise that this is one big loop were in case of dynamic addresses the TX_BUF is used for DHCP and if an address is found later on the same storage is used for web-server. I had seen other implementations were DHCP was one thread and web-server was a separate thread. If these both use the same storage (TX_BUF) you need to synchronize it. My final implementation is one network thread in freeRTOS for DHCP and web in one loop using a port of the WIZ550web server and the WIZ550web DHCP client.


I gave the wrong answer. I apologize first and correct it.
It is true that the hardware buffers are separate, but the software uses TX_BUF together.


Therefore, to use two threads, it is safe to specify the S / W buffer separately.
If you do not have enough memory to allocate buffers, we recommend that you proceed polling inside a single thread as you have already implemented.

Can you tell me which MCU you are using?


Best Regard,

Hi Kel,
I use an Atmel Xmega 128 a3u CPU which is 128kB flash and 8kByte RAM. So I have to be very careful with RAM usage. This board does not have any SD-Card, Flash, RAM extension because all Ports are in use and this special CPU does not have any pins able to handle external memory.
The port is not difficult. When I started I found 220% of RAM usage. This is based on avr-gcc. Each string has to be tagged as part of the flash. After tagging some *printf had been dropped and now with 1k for TX_BUF and RX_BUF everything fits into memory.


Oh, it’s a very small RAM size.
If so, we recommend that you use one Task instead of dividing the Task.

It seems that you can use the one network thread method that you implemented.