I am trying to use the raw API with NO_SYS = 1, and SYS_LIGHTWEIGHT_PROT
= 1 on a light-weight RTOS. In the design I am attempting, there are two
tasks: The network task, which processes incoming packets (after being notified
by an ETH ISR) and calls the *_tmr() functions periodically. The second
task handles time consuming requests (disk or uart I/O for example).
Is it safe to use tcp_write(), tcp_output(), etc from task
#2 in this scenario? So for example, in a connection being serviced by
the network task in the tcp_recv() callback, I get a request to read a file
from external memory. I hand that request off to a queue. When task
2 has nothing to do, it picks up that request, and reads the file into RAM and
in then calls tcp_write(). Do I need to put the tcp_write() call in
a critical section that blocks the network task from running? Or
would it be safer/better to have queues going both ways to where the network
task main loop checks for pending calls to tcp_write()? I know this kind
of thing could be accomplished in the tcp_poll() callback, but then there’s
a worst case latency of 500ms between when data is ready to send and when it
actually gets sent.