[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: another reentrancy question

From: shogun
Subject: [lwip-users] Re: another reentrancy question
Date: Wed, 24 Nov 2010 12:49:47 -0500

>Am 23.11.2010 um 03:19 schrieb "shogun" <address@hidden>:
>> .  Every time I stop it and
>> it is not working properly, it is in the file tcp_in.c, the function
>> tcp_input() and going between the two source lines below only:
>> (line 180) for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { 
>> (line 201) prev = pcb;
>That's a relatively clear indication that the pcb list is corrupted. And
below you give the reason for this: you are accessing lwIP >from the main
task and from interrupt level. I can only tell you again that this is NOT
SUPPORTED. You simply have to redesign your >usage of lwIP to make sure it
is not used at by the main task and interrupt handlers at the same time!

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 for both sending
and receiving, can this be done reliably if I use mutual exclusion on all
sends and receives?  I know this would be a poor way to implement  an
application but  is there any safe way to safely run two (asynchronous)
sockets without an RTOS?

It sounds like the best way to use two sockets is to run a RTOS.  Is the
best way to do this is have the callback from the receive(s) from the two
sockets  copy the data to a safe location in memory and then signal a task
via (que message/semaphore) and have the task process the data?  This is
typically the way data is handled is to get the data from the device in the
interrupt and get out ASAP.   In the receive callback, do any interrupts
need to be disabled in case more data is sent when the data is being copied?

Also, when sending data out of each of the two sockets, is there anything
that has to be done while sending data out to prevent any problems of data
being received since data can come asynchronously from the other side?

Thanks again, I am just want a better understanding of how I should use this

reply via email to

[Prev in Thread] Current Thread [Next in Thread]