|
From: | address@hidden |
Subject: | Re: [lwip-users] Re: another reentrancy question |
Date: | Wed, 24 Nov 2010 22:00:51 +0100 |
User-agent: | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 |
shogun wrote:
Can someone help me understand this better? I understand that I shouldn't send and receive from both main and an interrupt at the same time since the stack is not reentrant. I want to ask some questions to help me understand this better, not that this is the way I want to implement the application but I want to better understand this and what I should and shouldn't do. If I am not running an RTOS and I want to run two sockets
Are you sure you mean sockets here? Because at leat the socket API included in the lwIP sources dos not work wihout an OS. In that case, you can only use the raw API.
for both sending and receiving, can this be done reliably if I use mutual exclusion on all sends and receives?
The general idea of running lwIP wihtout an OS is to do all lwIP-related processing in a main loop (non-ISR context) and to use the ISR only to allocate a pbuf (PBUF_POOL may be allocated from ISR while PBUF_RAM is not supported there!) and copy the received data from the MAC to that pbuf. Then put the received pbuf on a list that you check (and thus process) in the main loop (i.e. non-ISR context). That's the default way to use lwIP without an OS.
If you follow this design, there's nothing more special to watch out for.Using a global lock does *not* work because you cannot delay an ISR context to let the main loop run first. OK, you *can* achieve locking out RX ISRs when entereing the stack by disabling RX interrupts, but that's more tricky and not guaranteed to achieve higher throughput.
Simon
[Prev in Thread] | Current Thread | [Next in Thread] |