I made a small network stack that's just meant to do ARP/ICMP and UDP, so its really small and fast (faster than uIP) and I have 1 thread handling the network traffic that calls callbacks based on which port the higher level api has registered. The network buffer is shared for data received and sent (like uIP) to save memory. So thread is something like this in pseudo code:
Code: Select all
While(1)
{
Wait interrupt with data ready to read
If read size > 0
Process packet
Endif
}
Now, while the packet is being processed, the buffer contents can be changed and used as the reply data if there is a reply, so far so good, but, sometimes, I have to send a sporadic packet outside of that thread packet processing, I have to figure out a way of just sending those packets when there is no packet being processes.
How would you guys tackle this issue ?
Best regards.